# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38274 | 2018-01-03T10:29:37 Z | mirbek01 | Bootfall (IZhO17_bootfall) | C++14 | 546 ms | 5796 KB |
# include <bits/stdc++.h> # define pb push_back # define fr first # define sc second # define mk make_pair using namespace std; const long long linf = 1e18 + 7; const int inf = 1e9 + 7; const int N = 250005; typedef long long ll; int n, a[N], dp[N], cnt[N], s; vector <int> ans; int main(){ dp[0] = 1; scanf("%d", &n); for(int i = 1; i <= n; i ++){ scanf("%d", &a[i]); s += a[i]; } for(int i = 1; i <= n; i ++) for(int j = s; j - a[i] >= 0; j --) dp[j] += dp[j - a[i]]; if(s % 2 || !dp[s / 2]) { cout << 0 << endl; return 0; } for(int i = 1; i <= n; i ++){ int ss = s - a[i]; for(int j = 0; j <= ss; j ++) dp[j + a[i]] = (dp[j + a[i]] - dp[j]); for(int j = ss / 2 + 1; j <= ss; j ++) if(dp[j]) cnt[j * 2 - ss] ++; for(int j = ss; j >= 0; j --) dp[j + a[i]] += dp[j]; } for(int i = 1; i <= s; i ++) if(cnt[i] == n) ans.pb(i); printf("%d\n", ans.size()); for(int i : ans) printf("%d ", i); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4944 KB | Output is correct |
2 | Correct | 0 ms | 4944 KB | Output is correct |
3 | Correct | 0 ms | 4944 KB | Output is correct |
4 | Correct | 0 ms | 4944 KB | Output is correct |
5 | Correct | 0 ms | 4944 KB | Output is correct |
6 | Correct | 0 ms | 4944 KB | Output is correct |
7 | Correct | 0 ms | 4944 KB | Output is correct |
8 | Correct | 0 ms | 4944 KB | Output is correct |
9 | Correct | 0 ms | 4944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4944 KB | Output is correct |
2 | Correct | 0 ms | 4944 KB | Output is correct |
3 | Correct | 0 ms | 4944 KB | Output is correct |
4 | Correct | 0 ms | 4944 KB | Output is correct |
5 | Correct | 0 ms | 4944 KB | Output is correct |
6 | Correct | 0 ms | 4944 KB | Output is correct |
7 | Correct | 0 ms | 4944 KB | Output is correct |
8 | Correct | 0 ms | 4944 KB | Output is correct |
9 | Correct | 0 ms | 4944 KB | Output is correct |
10 | Correct | 0 ms | 4944 KB | Output is correct |
11 | Correct | 0 ms | 4944 KB | Output is correct |
12 | Correct | 0 ms | 4944 KB | Output is correct |
13 | Correct | 0 ms | 4944 KB | Output is correct |
14 | Correct | 0 ms | 4944 KB | Output is correct |
15 | Correct | 0 ms | 4944 KB | Output is correct |
16 | Correct | 0 ms | 4944 KB | Output is correct |
17 | Correct | 0 ms | 4944 KB | Output is correct |
18 | Correct | 0 ms | 4944 KB | Output is correct |
19 | Correct | 0 ms | 4944 KB | Output is correct |
20 | Correct | 0 ms | 4944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4944 KB | Output is correct |
2 | Correct | 0 ms | 4944 KB | Output is correct |
3 | Correct | 0 ms | 4944 KB | Output is correct |
4 | Correct | 0 ms | 4944 KB | Output is correct |
5 | Correct | 0 ms | 4944 KB | Output is correct |
6 | Correct | 0 ms | 4944 KB | Output is correct |
7 | Correct | 0 ms | 4944 KB | Output is correct |
8 | Correct | 0 ms | 4944 KB | Output is correct |
9 | Correct | 0 ms | 4944 KB | Output is correct |
10 | Correct | 0 ms | 4944 KB | Output is correct |
11 | Correct | 0 ms | 4944 KB | Output is correct |
12 | Correct | 0 ms | 4944 KB | Output is correct |
13 | Correct | 0 ms | 4944 KB | Output is correct |
14 | Correct | 0 ms | 4944 KB | Output is correct |
15 | Correct | 0 ms | 4944 KB | Output is correct |
16 | Correct | 0 ms | 4944 KB | Output is correct |
17 | Correct | 0 ms | 4944 KB | Output is correct |
18 | Correct | 0 ms | 4944 KB | Output is correct |
19 | Correct | 0 ms | 4944 KB | Output is correct |
20 | Correct | 0 ms | 4944 KB | Output is correct |
21 | Correct | 0 ms | 4944 KB | Output is correct |
22 | Correct | 0 ms | 4944 KB | Output is correct |
23 | Correct | 0 ms | 4944 KB | Output is correct |
24 | Correct | 0 ms | 4944 KB | Output is correct |
25 | Correct | 3 ms | 4944 KB | Output is correct |
26 | Correct | 3 ms | 4944 KB | Output is correct |
27 | Correct | 6 ms | 4944 KB | Output is correct |
28 | Correct | 3 ms | 4944 KB | Output is correct |
29 | Correct | 3 ms | 4944 KB | Output is correct |
30 | Correct | 3 ms | 4944 KB | Output is correct |
31 | Correct | 3 ms | 4944 KB | Output is correct |
32 | Correct | 3 ms | 4944 KB | Output is correct |
33 | Correct | 3 ms | 4944 KB | Output is correct |
34 | Correct | 3 ms | 4944 KB | Output is correct |
35 | Correct | 3 ms | 4944 KB | Output is correct |
36 | Correct | 0 ms | 4944 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4944 KB | Output is correct |
2 | Correct | 0 ms | 4944 KB | Output is correct |
3 | Correct | 0 ms | 4944 KB | Output is correct |
4 | Correct | 0 ms | 4944 KB | Output is correct |
5 | Correct | 0 ms | 4944 KB | Output is correct |
6 | Correct | 0 ms | 4944 KB | Output is correct |
7 | Correct | 0 ms | 4944 KB | Output is correct |
8 | Correct | 0 ms | 4944 KB | Output is correct |
9 | Correct | 0 ms | 4944 KB | Output is correct |
10 | Correct | 0 ms | 4944 KB | Output is correct |
11 | Correct | 0 ms | 4944 KB | Output is correct |
12 | Correct | 0 ms | 4944 KB | Output is correct |
13 | Correct | 0 ms | 4944 KB | Output is correct |
14 | Correct | 0 ms | 4944 KB | Output is correct |
15 | Correct | 0 ms | 4944 KB | Output is correct |
16 | Correct | 0 ms | 4944 KB | Output is correct |
17 | Correct | 0 ms | 4944 KB | Output is correct |
18 | Correct | 0 ms | 4944 KB | Output is correct |
19 | Correct | 0 ms | 4944 KB | Output is correct |
20 | Correct | 0 ms | 4944 KB | Output is correct |
21 | Correct | 0 ms | 4944 KB | Output is correct |
22 | Correct | 0 ms | 4944 KB | Output is correct |
23 | Correct | 0 ms | 4944 KB | Output is correct |
24 | Correct | 0 ms | 4944 KB | Output is correct |
25 | Correct | 3 ms | 4944 KB | Output is correct |
26 | Correct | 3 ms | 4944 KB | Output is correct |
27 | Correct | 6 ms | 4944 KB | Output is correct |
28 | Correct | 3 ms | 4944 KB | Output is correct |
29 | Correct | 3 ms | 4944 KB | Output is correct |
30 | Correct | 3 ms | 4944 KB | Output is correct |
31 | Correct | 3 ms | 4944 KB | Output is correct |
32 | Correct | 3 ms | 4944 KB | Output is correct |
33 | Correct | 3 ms | 4944 KB | Output is correct |
34 | Correct | 3 ms | 4944 KB | Output is correct |
35 | Correct | 3 ms | 4944 KB | Output is correct |
36 | Correct | 0 ms | 4944 KB | Output is correct |
37 | Correct | 29 ms | 5084 KB | Output is correct |
38 | Correct | 16 ms | 5084 KB | Output is correct |
39 | Correct | 63 ms | 4944 KB | Output is correct |
40 | Correct | 39 ms | 5084 KB | Output is correct |
41 | Correct | 73 ms | 4944 KB | Output is correct |
42 | Correct | 29 ms | 5084 KB | Output is correct |
43 | Correct | 56 ms | 5216 KB | Output is correct |
44 | Correct | 59 ms | 5216 KB | Output is correct |
45 | Correct | 59 ms | 5216 KB | Output is correct |
46 | Correct | 33 ms | 4944 KB | Output is correct |
47 | Correct | 39 ms | 5084 KB | Output is correct |
48 | Correct | 69 ms | 5216 KB | Output is correct |
49 | Correct | 79 ms | 5084 KB | Output is correct |
50 | Correct | 33 ms | 5084 KB | Output is correct |
51 | Correct | 9 ms | 4944 KB | Output is correct |
52 | Correct | 79 ms | 5216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4944 KB | Output is correct |
2 | Correct | 0 ms | 4944 KB | Output is correct |
3 | Correct | 0 ms | 4944 KB | Output is correct |
4 | Correct | 0 ms | 4944 KB | Output is correct |
5 | Correct | 0 ms | 4944 KB | Output is correct |
6 | Correct | 0 ms | 4944 KB | Output is correct |
7 | Correct | 0 ms | 4944 KB | Output is correct |
8 | Correct | 0 ms | 4944 KB | Output is correct |
9 | Correct | 0 ms | 4944 KB | Output is correct |
10 | Correct | 0 ms | 4944 KB | Output is correct |
11 | Correct | 0 ms | 4944 KB | Output is correct |
12 | Correct | 0 ms | 4944 KB | Output is correct |
13 | Correct | 0 ms | 4944 KB | Output is correct |
14 | Correct | 0 ms | 4944 KB | Output is correct |
15 | Correct | 0 ms | 4944 KB | Output is correct |
16 | Correct | 0 ms | 4944 KB | Output is correct |
17 | Correct | 0 ms | 4944 KB | Output is correct |
18 | Correct | 0 ms | 4944 KB | Output is correct |
19 | Correct | 0 ms | 4944 KB | Output is correct |
20 | Correct | 0 ms | 4944 KB | Output is correct |
21 | Correct | 0 ms | 4944 KB | Output is correct |
22 | Correct | 0 ms | 4944 KB | Output is correct |
23 | Correct | 0 ms | 4944 KB | Output is correct |
24 | Correct | 0 ms | 4944 KB | Output is correct |
25 | Correct | 3 ms | 4944 KB | Output is correct |
26 | Correct | 3 ms | 4944 KB | Output is correct |
27 | Correct | 6 ms | 4944 KB | Output is correct |
28 | Correct | 3 ms | 4944 KB | Output is correct |
29 | Correct | 3 ms | 4944 KB | Output is correct |
30 | Correct | 3 ms | 4944 KB | Output is correct |
31 | Correct | 3 ms | 4944 KB | Output is correct |
32 | Correct | 3 ms | 4944 KB | Output is correct |
33 | Correct | 3 ms | 4944 KB | Output is correct |
34 | Correct | 3 ms | 4944 KB | Output is correct |
35 | Correct | 3 ms | 4944 KB | Output is correct |
36 | Correct | 0 ms | 4944 KB | Output is correct |
37 | Correct | 29 ms | 5084 KB | Output is correct |
38 | Correct | 16 ms | 5084 KB | Output is correct |
39 | Correct | 63 ms | 4944 KB | Output is correct |
40 | Correct | 39 ms | 5084 KB | Output is correct |
41 | Correct | 73 ms | 4944 KB | Output is correct |
42 | Correct | 29 ms | 5084 KB | Output is correct |
43 | Correct | 56 ms | 5216 KB | Output is correct |
44 | Correct | 59 ms | 5216 KB | Output is correct |
45 | Correct | 59 ms | 5216 KB | Output is correct |
46 | Correct | 33 ms | 4944 KB | Output is correct |
47 | Correct | 39 ms | 5084 KB | Output is correct |
48 | Correct | 69 ms | 5216 KB | Output is correct |
49 | Correct | 79 ms | 5084 KB | Output is correct |
50 | Correct | 33 ms | 5084 KB | Output is correct |
51 | Correct | 9 ms | 4944 KB | Output is correct |
52 | Correct | 79 ms | 5216 KB | Output is correct |
53 | Correct | 59 ms | 5216 KB | Output is correct |
54 | Correct | 79 ms | 5216 KB | Output is correct |
55 | Correct | 169 ms | 5412 KB | Output is correct |
56 | Correct | 76 ms | 5216 KB | Output is correct |
57 | Correct | 176 ms | 5412 KB | Output is correct |
58 | Correct | 96 ms | 5216 KB | Output is correct |
59 | Correct | 116 ms | 5412 KB | Output is correct |
60 | Correct | 26 ms | 4944 KB | Output is correct |
61 | Correct | 133 ms | 5412 KB | Output is correct |
62 | Correct | 126 ms | 5412 KB | Output is correct |
63 | Correct | 156 ms | 5412 KB | Output is correct |
64 | Correct | 136 ms | 5412 KB | Output is correct |
65 | Correct | 73 ms | 4944 KB | Output is correct |
66 | Correct | 66 ms | 5084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4944 KB | Output is correct |
2 | Correct | 0 ms | 4944 KB | Output is correct |
3 | Correct | 0 ms | 4944 KB | Output is correct |
4 | Correct | 0 ms | 4944 KB | Output is correct |
5 | Correct | 0 ms | 4944 KB | Output is correct |
6 | Correct | 0 ms | 4944 KB | Output is correct |
7 | Correct | 0 ms | 4944 KB | Output is correct |
8 | Correct | 0 ms | 4944 KB | Output is correct |
9 | Correct | 0 ms | 4944 KB | Output is correct |
10 | Correct | 0 ms | 4944 KB | Output is correct |
11 | Correct | 0 ms | 4944 KB | Output is correct |
12 | Correct | 0 ms | 4944 KB | Output is correct |
13 | Correct | 0 ms | 4944 KB | Output is correct |
14 | Correct | 0 ms | 4944 KB | Output is correct |
15 | Correct | 0 ms | 4944 KB | Output is correct |
16 | Correct | 0 ms | 4944 KB | Output is correct |
17 | Correct | 0 ms | 4944 KB | Output is correct |
18 | Correct | 0 ms | 4944 KB | Output is correct |
19 | Correct | 0 ms | 4944 KB | Output is correct |
20 | Correct | 0 ms | 4944 KB | Output is correct |
21 | Correct | 0 ms | 4944 KB | Output is correct |
22 | Correct | 0 ms | 4944 KB | Output is correct |
23 | Correct | 0 ms | 4944 KB | Output is correct |
24 | Correct | 0 ms | 4944 KB | Output is correct |
25 | Correct | 3 ms | 4944 KB | Output is correct |
26 | Correct | 3 ms | 4944 KB | Output is correct |
27 | Correct | 6 ms | 4944 KB | Output is correct |
28 | Correct | 3 ms | 4944 KB | Output is correct |
29 | Correct | 3 ms | 4944 KB | Output is correct |
30 | Correct | 3 ms | 4944 KB | Output is correct |
31 | Correct | 3 ms | 4944 KB | Output is correct |
32 | Correct | 3 ms | 4944 KB | Output is correct |
33 | Correct | 3 ms | 4944 KB | Output is correct |
34 | Correct | 3 ms | 4944 KB | Output is correct |
35 | Correct | 3 ms | 4944 KB | Output is correct |
36 | Correct | 0 ms | 4944 KB | Output is correct |
37 | Correct | 29 ms | 5084 KB | Output is correct |
38 | Correct | 16 ms | 5084 KB | Output is correct |
39 | Correct | 63 ms | 4944 KB | Output is correct |
40 | Correct | 39 ms | 5084 KB | Output is correct |
41 | Correct | 73 ms | 4944 KB | Output is correct |
42 | Correct | 29 ms | 5084 KB | Output is correct |
43 | Correct | 56 ms | 5216 KB | Output is correct |
44 | Correct | 59 ms | 5216 KB | Output is correct |
45 | Correct | 59 ms | 5216 KB | Output is correct |
46 | Correct | 33 ms | 4944 KB | Output is correct |
47 | Correct | 39 ms | 5084 KB | Output is correct |
48 | Correct | 69 ms | 5216 KB | Output is correct |
49 | Correct | 79 ms | 5084 KB | Output is correct |
50 | Correct | 33 ms | 5084 KB | Output is correct |
51 | Correct | 9 ms | 4944 KB | Output is correct |
52 | Correct | 79 ms | 5216 KB | Output is correct |
53 | Correct | 59 ms | 5216 KB | Output is correct |
54 | Correct | 79 ms | 5216 KB | Output is correct |
55 | Correct | 169 ms | 5412 KB | Output is correct |
56 | Correct | 76 ms | 5216 KB | Output is correct |
57 | Correct | 176 ms | 5412 KB | Output is correct |
58 | Correct | 96 ms | 5216 KB | Output is correct |
59 | Correct | 116 ms | 5412 KB | Output is correct |
60 | Correct | 26 ms | 4944 KB | Output is correct |
61 | Correct | 133 ms | 5412 KB | Output is correct |
62 | Correct | 126 ms | 5412 KB | Output is correct |
63 | Correct | 156 ms | 5412 KB | Output is correct |
64 | Correct | 136 ms | 5412 KB | Output is correct |
65 | Correct | 73 ms | 4944 KB | Output is correct |
66 | Correct | 66 ms | 5084 KB | Output is correct |
67 | Correct | 146 ms | 5412 KB | Output is correct |
68 | Correct | 86 ms | 4944 KB | Output is correct |
69 | Correct | 486 ms | 5796 KB | Output is correct |
70 | Correct | 263 ms | 5412 KB | Output is correct |
71 | Correct | 279 ms | 5412 KB | Output is correct |
72 | Correct | 259 ms | 4944 KB | Output is correct |
73 | Correct | 273 ms | 4944 KB | Output is correct |
74 | Correct | 499 ms | 5796 KB | Output is correct |
75 | Correct | 403 ms | 5796 KB | Output is correct |
76 | Correct | 543 ms | 5796 KB | Output is correct |
77 | Correct | 546 ms | 5796 KB | Output is correct |