# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91479 | 2018-12-27T16:35:07 Z | davitmarg | Bootfall (IZhO17_bootfall) | C++17 | 390 ms | 6384 KB |
/* DEATH-MATCH Davit-Marg */ #include <iostream> #include <algorithm> #include <cmath> #include <cassert> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iterator> #include <ctype.h> #include <stdlib.h> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back using namespace std; LL n,a[5000006],cant[5000006]; LL sum,sm; vector<LL> ans; LL dp[5000006]; void add(LL k) { sum += k; for (LL j = sum; j >= 0; j--) dp[j + k] += dp[j]; } void rem(LL k) { for (LL i = 0; i <= sum; i++) dp[i + k] -= dp[i]; sum -= k; } int main() { cin >> n; for (LL i = 0; i < n; i++) { cin >> a[i]; sm += a[i]; } dp[0] = 1ll; for (LL i = 0; i < n; i++) add(a[i]); if (sm % 2==1 || dp[sm / 2] == 0) { cout << 0 << endl; return 0; } for (LL i = 0; i < n; i++) { rem(a[i]); for (LL j = 0; j <= sm; j++) { //assert(dp[(sum + j) / 2]<0); if ((sum + j) % 2 == 1 || dp[(sum + j) / 2] == 0) cant[j] = 1; } add(a[i]); } for (LL j = 0; j <= sm; j++) if (!cant[j]) ans.PB(j); cout << ans.size() << endl; for (LL i = 0; i < ans.size(); i++) cout << ans[i] << " "; cout << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 508 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 2 ms | 508 KB | Output is correct |
9 | Correct | 2 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 508 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 2 ms | 508 KB | Output is correct |
9 | Correct | 2 ms | 508 KB | Output is correct |
10 | Correct | 2 ms | 516 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 644 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 2 ms | 688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 508 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 2 ms | 508 KB | Output is correct |
9 | Correct | 2 ms | 508 KB | Output is correct |
10 | Correct | 2 ms | 516 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 644 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 2 ms | 688 KB | Output is correct |
21 | Correct | 2 ms | 688 KB | Output is correct |
22 | Correct | 3 ms | 688 KB | Output is correct |
23 | Correct | 2 ms | 688 KB | Output is correct |
24 | Correct | 4 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 820 KB | Output is correct |
26 | Correct | 5 ms | 824 KB | Output is correct |
27 | Correct | 5 ms | 828 KB | Output is correct |
28 | Correct | 6 ms | 836 KB | Output is correct |
29 | Correct | 5 ms | 836 KB | Output is correct |
30 | Correct | 4 ms | 836 KB | Output is correct |
31 | Correct | 5 ms | 844 KB | Output is correct |
32 | Correct | 3 ms | 848 KB | Output is correct |
33 | Correct | 5 ms | 852 KB | Output is correct |
34 | Correct | 5 ms | 856 KB | Output is correct |
35 | Correct | 5 ms | 940 KB | Output is correct |
36 | Correct | 4 ms | 940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 508 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 2 ms | 508 KB | Output is correct |
9 | Correct | 2 ms | 508 KB | Output is correct |
10 | Correct | 2 ms | 516 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 644 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 2 ms | 688 KB | Output is correct |
21 | Correct | 2 ms | 688 KB | Output is correct |
22 | Correct | 3 ms | 688 KB | Output is correct |
23 | Correct | 2 ms | 688 KB | Output is correct |
24 | Correct | 4 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 820 KB | Output is correct |
26 | Correct | 5 ms | 824 KB | Output is correct |
27 | Correct | 5 ms | 828 KB | Output is correct |
28 | Correct | 6 ms | 836 KB | Output is correct |
29 | Correct | 5 ms | 836 KB | Output is correct |
30 | Correct | 4 ms | 836 KB | Output is correct |
31 | Correct | 5 ms | 844 KB | Output is correct |
32 | Correct | 3 ms | 848 KB | Output is correct |
33 | Correct | 5 ms | 852 KB | Output is correct |
34 | Correct | 5 ms | 856 KB | Output is correct |
35 | Correct | 5 ms | 940 KB | Output is correct |
36 | Correct | 4 ms | 940 KB | Output is correct |
37 | Correct | 14 ms | 1312 KB | Output is correct |
38 | Correct | 15 ms | 1312 KB | Output is correct |
39 | Correct | 53 ms | 1728 KB | Output is correct |
40 | Correct | 29 ms | 1728 KB | Output is correct |
41 | Correct | 66 ms | 1900 KB | Output is correct |
42 | Correct | 27 ms | 1900 KB | Output is correct |
43 | Correct | 44 ms | 2036 KB | Output is correct |
44 | Correct | 46 ms | 2040 KB | Output is correct |
45 | Correct | 48 ms | 2044 KB | Output is correct |
46 | Correct | 33 ms | 2044 KB | Output is correct |
47 | Correct | 29 ms | 2044 KB | Output is correct |
48 | Correct | 54 ms | 2160 KB | Output is correct |
49 | Correct | 59 ms | 2160 KB | Output is correct |
50 | Correct | 29 ms | 2160 KB | Output is correct |
51 | Correct | 5 ms | 2160 KB | Output is correct |
52 | Correct | 62 ms | 2340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 508 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 2 ms | 508 KB | Output is correct |
9 | Correct | 2 ms | 508 KB | Output is correct |
10 | Correct | 2 ms | 516 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 644 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 2 ms | 688 KB | Output is correct |
21 | Correct | 2 ms | 688 KB | Output is correct |
22 | Correct | 3 ms | 688 KB | Output is correct |
23 | Correct | 2 ms | 688 KB | Output is correct |
24 | Correct | 4 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 820 KB | Output is correct |
26 | Correct | 5 ms | 824 KB | Output is correct |
27 | Correct | 5 ms | 828 KB | Output is correct |
28 | Correct | 6 ms | 836 KB | Output is correct |
29 | Correct | 5 ms | 836 KB | Output is correct |
30 | Correct | 4 ms | 836 KB | Output is correct |
31 | Correct | 5 ms | 844 KB | Output is correct |
32 | Correct | 3 ms | 848 KB | Output is correct |
33 | Correct | 5 ms | 852 KB | Output is correct |
34 | Correct | 5 ms | 856 KB | Output is correct |
35 | Correct | 5 ms | 940 KB | Output is correct |
36 | Correct | 4 ms | 940 KB | Output is correct |
37 | Correct | 14 ms | 1312 KB | Output is correct |
38 | Correct | 15 ms | 1312 KB | Output is correct |
39 | Correct | 53 ms | 1728 KB | Output is correct |
40 | Correct | 29 ms | 1728 KB | Output is correct |
41 | Correct | 66 ms | 1900 KB | Output is correct |
42 | Correct | 27 ms | 1900 KB | Output is correct |
43 | Correct | 44 ms | 2036 KB | Output is correct |
44 | Correct | 46 ms | 2040 KB | Output is correct |
45 | Correct | 48 ms | 2044 KB | Output is correct |
46 | Correct | 33 ms | 2044 KB | Output is correct |
47 | Correct | 29 ms | 2044 KB | Output is correct |
48 | Correct | 54 ms | 2160 KB | Output is correct |
49 | Correct | 59 ms | 2160 KB | Output is correct |
50 | Correct | 29 ms | 2160 KB | Output is correct |
51 | Correct | 5 ms | 2160 KB | Output is correct |
52 | Correct | 62 ms | 2340 KB | Output is correct |
53 | Correct | 49 ms | 2340 KB | Output is correct |
54 | Correct | 62 ms | 2340 KB | Output is correct |
55 | Correct | 124 ms | 3368 KB | Output is correct |
56 | Correct | 61 ms | 3368 KB | Output is correct |
57 | Correct | 133 ms | 3504 KB | Output is correct |
58 | Correct | 73 ms | 3504 KB | Output is correct |
59 | Correct | 87 ms | 3504 KB | Output is correct |
60 | Correct | 11 ms | 3504 KB | Output is correct |
61 | Correct | 99 ms | 3504 KB | Output is correct |
62 | Correct | 106 ms | 3504 KB | Output is correct |
63 | Correct | 109 ms | 3504 KB | Output is correct |
64 | Correct | 106 ms | 3504 KB | Output is correct |
65 | Correct | 56 ms | 3504 KB | Output is correct |
66 | Correct | 62 ms | 3504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 2 ms | 508 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 508 KB | Output is correct |
8 | Correct | 2 ms | 508 KB | Output is correct |
9 | Correct | 2 ms | 508 KB | Output is correct |
10 | Correct | 2 ms | 516 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 644 KB | Output is correct |
17 | Correct | 2 ms | 688 KB | Output is correct |
18 | Correct | 2 ms | 688 KB | Output is correct |
19 | Correct | 2 ms | 688 KB | Output is correct |
20 | Correct | 2 ms | 688 KB | Output is correct |
21 | Correct | 2 ms | 688 KB | Output is correct |
22 | Correct | 3 ms | 688 KB | Output is correct |
23 | Correct | 2 ms | 688 KB | Output is correct |
24 | Correct | 4 ms | 800 KB | Output is correct |
25 | Correct | 5 ms | 820 KB | Output is correct |
26 | Correct | 5 ms | 824 KB | Output is correct |
27 | Correct | 5 ms | 828 KB | Output is correct |
28 | Correct | 6 ms | 836 KB | Output is correct |
29 | Correct | 5 ms | 836 KB | Output is correct |
30 | Correct | 4 ms | 836 KB | Output is correct |
31 | Correct | 5 ms | 844 KB | Output is correct |
32 | Correct | 3 ms | 848 KB | Output is correct |
33 | Correct | 5 ms | 852 KB | Output is correct |
34 | Correct | 5 ms | 856 KB | Output is correct |
35 | Correct | 5 ms | 940 KB | Output is correct |
36 | Correct | 4 ms | 940 KB | Output is correct |
37 | Correct | 14 ms | 1312 KB | Output is correct |
38 | Correct | 15 ms | 1312 KB | Output is correct |
39 | Correct | 53 ms | 1728 KB | Output is correct |
40 | Correct | 29 ms | 1728 KB | Output is correct |
41 | Correct | 66 ms | 1900 KB | Output is correct |
42 | Correct | 27 ms | 1900 KB | Output is correct |
43 | Correct | 44 ms | 2036 KB | Output is correct |
44 | Correct | 46 ms | 2040 KB | Output is correct |
45 | Correct | 48 ms | 2044 KB | Output is correct |
46 | Correct | 33 ms | 2044 KB | Output is correct |
47 | Correct | 29 ms | 2044 KB | Output is correct |
48 | Correct | 54 ms | 2160 KB | Output is correct |
49 | Correct | 59 ms | 2160 KB | Output is correct |
50 | Correct | 29 ms | 2160 KB | Output is correct |
51 | Correct | 5 ms | 2160 KB | Output is correct |
52 | Correct | 62 ms | 2340 KB | Output is correct |
53 | Correct | 49 ms | 2340 KB | Output is correct |
54 | Correct | 62 ms | 2340 KB | Output is correct |
55 | Correct | 124 ms | 3368 KB | Output is correct |
56 | Correct | 61 ms | 3368 KB | Output is correct |
57 | Correct | 133 ms | 3504 KB | Output is correct |
58 | Correct | 73 ms | 3504 KB | Output is correct |
59 | Correct | 87 ms | 3504 KB | Output is correct |
60 | Correct | 11 ms | 3504 KB | Output is correct |
61 | Correct | 99 ms | 3504 KB | Output is correct |
62 | Correct | 106 ms | 3504 KB | Output is correct |
63 | Correct | 109 ms | 3504 KB | Output is correct |
64 | Correct | 106 ms | 3504 KB | Output is correct |
65 | Correct | 56 ms | 3504 KB | Output is correct |
66 | Correct | 62 ms | 3504 KB | Output is correct |
67 | Correct | 105 ms | 3504 KB | Output is correct |
68 | Correct | 27 ms | 3504 KB | Output is correct |
69 | Correct | 346 ms | 5756 KB | Output is correct |
70 | Correct | 200 ms | 5756 KB | Output is correct |
71 | Correct | 195 ms | 5756 KB | Output is correct |
72 | Correct | 191 ms | 5756 KB | Output is correct |
73 | Correct | 190 ms | 5756 KB | Output is correct |
74 | Correct | 347 ms | 6124 KB | Output is correct |
75 | Correct | 346 ms | 6124 KB | Output is correct |
76 | Correct | 390 ms | 6380 KB | Output is correct |
77 | Correct | 371 ms | 6384 KB | Output is correct |