# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335547 | 2020-12-13T03:57:42 Z | luciocf | Bootfall (IZhO17_bootfall) | C++14 | 97 ms | 2796 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 510; const int maxs = 250010; const int mod = 1e9+7; int a[maxn]; int dp[maxs], qtd[maxs]; int main(void) { int n; scanf("%d", &n); int s = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); s += a[i]; } dp[0] = 1; for (int i = 1; i <= n; i++) for (int j = maxs-1; j >= a[i]; j--) dp[j] += dp[j - a[i]]; if (s&1 || !dp[s/2]) { printf("0\n"); return 0; } for (int i = 1; i <= n; i++) { for (int j = a[i]; j < maxs; j++) dp[j] = (dp[j] - dp[j - a[i]] + mod)%mod; for (int j = (s-a[i]+1)/2; j < maxs; j++) if (dp[j]) qtd[2*j-s+a[i]]++; for (int j = maxs; j >= a[i]; j--) dp[j] = (dp[j] + dp[j - a[i]])%mod; } int ans = 0; for (int i = 1; i < maxs; i++) if (qtd[i] == n) ans++; printf("%d\n", ans); for (int i = 1; i < maxs; i++) if (qtd[i] == n) printf("%d ", i); printf("\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1260 KB | Output is correct |
2 | Correct | 10 ms | 1260 KB | Output is correct |
3 | Correct | 2 ms | 1260 KB | Output is correct |
4 | Correct | 7 ms | 1260 KB | Output is correct |
5 | Correct | 18 ms | 1260 KB | Output is correct |
6 | Correct | 13 ms | 1260 KB | Output is correct |
7 | Correct | 10 ms | 1260 KB | Output is correct |
8 | Correct | 19 ms | 1260 KB | Output is correct |
9 | Correct | 15 ms | 1260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1260 KB | Output is correct |
2 | Correct | 10 ms | 1260 KB | Output is correct |
3 | Correct | 2 ms | 1260 KB | Output is correct |
4 | Correct | 7 ms | 1260 KB | Output is correct |
5 | Correct | 18 ms | 1260 KB | Output is correct |
6 | Correct | 13 ms | 1260 KB | Output is correct |
7 | Correct | 10 ms | 1260 KB | Output is correct |
8 | Correct | 19 ms | 1260 KB | Output is correct |
9 | Correct | 15 ms | 1260 KB | Output is correct |
10 | Correct | 47 ms | 1280 KB | Output is correct |
11 | Correct | 47 ms | 1260 KB | Output is correct |
12 | Correct | 57 ms | 1260 KB | Output is correct |
13 | Correct | 39 ms | 1260 KB | Output is correct |
14 | Correct | 41 ms | 1280 KB | Output is correct |
15 | Correct | 45 ms | 1260 KB | Output is correct |
16 | Correct | 48 ms | 1360 KB | Output is correct |
17 | Correct | 28 ms | 1260 KB | Output is correct |
18 | Correct | 46 ms | 1260 KB | Output is correct |
19 | Correct | 39 ms | 1360 KB | Output is correct |
20 | Correct | 45 ms | 1260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1260 KB | Output is correct |
2 | Correct | 10 ms | 1260 KB | Output is correct |
3 | Correct | 2 ms | 1260 KB | Output is correct |
4 | Correct | 7 ms | 1260 KB | Output is correct |
5 | Correct | 18 ms | 1260 KB | Output is correct |
6 | Correct | 13 ms | 1260 KB | Output is correct |
7 | Correct | 10 ms | 1260 KB | Output is correct |
8 | Correct | 19 ms | 1260 KB | Output is correct |
9 | Correct | 15 ms | 1260 KB | Output is correct |
10 | Correct | 47 ms | 1280 KB | Output is correct |
11 | Correct | 47 ms | 1260 KB | Output is correct |
12 | Correct | 57 ms | 1260 KB | Output is correct |
13 | Correct | 39 ms | 1260 KB | Output is correct |
14 | Correct | 41 ms | 1280 KB | Output is correct |
15 | Correct | 45 ms | 1260 KB | Output is correct |
16 | Correct | 48 ms | 1360 KB | Output is correct |
17 | Correct | 28 ms | 1260 KB | Output is correct |
18 | Correct | 46 ms | 1260 KB | Output is correct |
19 | Correct | 39 ms | 1360 KB | Output is correct |
20 | Correct | 45 ms | 1260 KB | Output is correct |
21 | Incorrect | 97 ms | 2796 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1260 KB | Output is correct |
2 | Correct | 10 ms | 1260 KB | Output is correct |
3 | Correct | 2 ms | 1260 KB | Output is correct |
4 | Correct | 7 ms | 1260 KB | Output is correct |
5 | Correct | 18 ms | 1260 KB | Output is correct |
6 | Correct | 13 ms | 1260 KB | Output is correct |
7 | Correct | 10 ms | 1260 KB | Output is correct |
8 | Correct | 19 ms | 1260 KB | Output is correct |
9 | Correct | 15 ms | 1260 KB | Output is correct |
10 | Correct | 47 ms | 1280 KB | Output is correct |
11 | Correct | 47 ms | 1260 KB | Output is correct |
12 | Correct | 57 ms | 1260 KB | Output is correct |
13 | Correct | 39 ms | 1260 KB | Output is correct |
14 | Correct | 41 ms | 1280 KB | Output is correct |
15 | Correct | 45 ms | 1260 KB | Output is correct |
16 | Correct | 48 ms | 1360 KB | Output is correct |
17 | Correct | 28 ms | 1260 KB | Output is correct |
18 | Correct | 46 ms | 1260 KB | Output is correct |
19 | Correct | 39 ms | 1360 KB | Output is correct |
20 | Correct | 45 ms | 1260 KB | Output is correct |
21 | Incorrect | 97 ms | 2796 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1260 KB | Output is correct |
2 | Correct | 10 ms | 1260 KB | Output is correct |
3 | Correct | 2 ms | 1260 KB | Output is correct |
4 | Correct | 7 ms | 1260 KB | Output is correct |
5 | Correct | 18 ms | 1260 KB | Output is correct |
6 | Correct | 13 ms | 1260 KB | Output is correct |
7 | Correct | 10 ms | 1260 KB | Output is correct |
8 | Correct | 19 ms | 1260 KB | Output is correct |
9 | Correct | 15 ms | 1260 KB | Output is correct |
10 | Correct | 47 ms | 1280 KB | Output is correct |
11 | Correct | 47 ms | 1260 KB | Output is correct |
12 | Correct | 57 ms | 1260 KB | Output is correct |
13 | Correct | 39 ms | 1260 KB | Output is correct |
14 | Correct | 41 ms | 1280 KB | Output is correct |
15 | Correct | 45 ms | 1260 KB | Output is correct |
16 | Correct | 48 ms | 1360 KB | Output is correct |
17 | Correct | 28 ms | 1260 KB | Output is correct |
18 | Correct | 46 ms | 1260 KB | Output is correct |
19 | Correct | 39 ms | 1360 KB | Output is correct |
20 | Correct | 45 ms | 1260 KB | Output is correct |
21 | Incorrect | 97 ms | 2796 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1260 KB | Output is correct |
2 | Correct | 10 ms | 1260 KB | Output is correct |
3 | Correct | 2 ms | 1260 KB | Output is correct |
4 | Correct | 7 ms | 1260 KB | Output is correct |
5 | Correct | 18 ms | 1260 KB | Output is correct |
6 | Correct | 13 ms | 1260 KB | Output is correct |
7 | Correct | 10 ms | 1260 KB | Output is correct |
8 | Correct | 19 ms | 1260 KB | Output is correct |
9 | Correct | 15 ms | 1260 KB | Output is correct |
10 | Correct | 47 ms | 1280 KB | Output is correct |
11 | Correct | 47 ms | 1260 KB | Output is correct |
12 | Correct | 57 ms | 1260 KB | Output is correct |
13 | Correct | 39 ms | 1260 KB | Output is correct |
14 | Correct | 41 ms | 1280 KB | Output is correct |
15 | Correct | 45 ms | 1260 KB | Output is correct |
16 | Correct | 48 ms | 1360 KB | Output is correct |
17 | Correct | 28 ms | 1260 KB | Output is correct |
18 | Correct | 46 ms | 1260 KB | Output is correct |
19 | Correct | 39 ms | 1360 KB | Output is correct |
20 | Correct | 45 ms | 1260 KB | Output is correct |
21 | Incorrect | 97 ms | 2796 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |