Submission #1694765
Source Code Expand
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.bitmanip; // BitArray void main() { auto rd = readln.split.to!(int[]), n = rd[0], x = rd[1]; auto w = new int[](n); foreach (i; 0..n) w[i] = readln.chomp.to!int; if (n == 1) { writeln(x == w[0] ? 1 : 0); return; } auto n1 = n/2, n2 = n-n1; auto s2 = new int[](1<<n2); foreach (i; 0..1<<n2) s2[i] = w[n1..$].indexed(i.bitsSet).sum; auto s2s = s2.sort(); auto ans = 0u; foreach (i; 0..1<<n1) { auto s1 = w.indexed(i.bitsSet).sum; ans += s2s.equalRange(x-s1).length; } writeln(ans); }
Submission Info
Submission Time | |
---|---|
Task | C - 無駄なものが嫌いな人 |
User | tesh |
Language | D (DMD64 v2.070.1) |
Score | 100 |
Code Size | 643 Byte |
Status | AC |
Exec Time | 26 ms |
Memory | 2556 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | max_1.txt, max_2.txt, max_3.txt, max_4.txt, pair_1.txt, pair_2.txt, power2_1.txt, power2_2.txt, power2_3.txt, power2_4.txt, power2_5.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
max_1.txt | AC | 23 ms | 508 KB |
max_2.txt | AC | 21 ms | 508 KB |
max_3.txt | AC | 21 ms | 508 KB |
max_4.txt | AC | 23 ms | 508 KB |
pair_1.txt | AC | 25 ms | 508 KB |
pair_2.txt | AC | 26 ms | 2556 KB |
power2_1.txt | AC | 20 ms | 508 KB |
power2_2.txt | AC | 19 ms | 2556 KB |
power2_3.txt | AC | 24 ms | 508 KB |
power2_4.txt | AC | 23 ms | 2556 KB |
power2_5.txt | AC | 2 ms | 256 KB |
random_1.txt | AC | 18 ms | 508 KB |
random_2.txt | AC | 18 ms | 508 KB |
random_3.txt | AC | 21 ms | 2556 KB |
random_4.txt | AC | 24 ms | 508 KB |
random_5.txt | AC | 23 ms | 508 KB |
random_6.txt | AC | 17 ms | 508 KB |
random_7.txt | AC | 26 ms | 508 KB |
random_8.txt | AC | 23 ms | 508 KB |
random_9.txt | AC | 17 ms | 508 KB |
sample_1.txt | AC | 1 ms | 256 KB |
sample_2.txt | AC | 1 ms | 256 KB |
sample_3.txt | AC | 1 ms | 256 KB |
sample_4.txt | AC | 1 ms | 256 KB |
small_1.txt | AC | 1 ms | 256 KB |
small_2.txt | AC | 1 ms | 256 KB |
small_3.txt | AC | 1 ms | 256 KB |
small_4.txt | AC | 1 ms | 256 KB |