# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
700123 | 2023-02-18T16:32:50 Z | fdnfksd | Bootfall (IZhO17_bootfall) | C++14 | 1000 ms | 3116 KB |
/// #include<bits/stdc++.h> #define task "C" #define ll long long #define ld long double #define fi first #define se second #define pb push_back using namespace std; const int MAXN = 5e2 + 5; const ll INF = 1e18 + 5; const int MOD = 1e9 + 22071997; int n; int a[MAXN], sum = 0; void Input() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; } } int dp[MAXN * MAXN], chk[MAXN * MAXN]; inline void add(int& a, int b) { a += b; if (a >= MOD) a -= MOD; if (a < 0) a += MOD; } void Solve() { if (sum % 2) { cout << 0; return; } dp[0] = 1; for (int i = 1; i <= n; i++) { for (int j = sum; j >= a[i]; j--) { add(dp[j], dp[j - a[i]]); } } if (!dp[sum / 2]) { cout << 0; return; } for (int i = 1; i <= n; i++) { for (int j = a[i]; j <= sum; j++) { add(dp[j], -dp[j - a[i]]); } for (int j = 0; j <= (sum - a[i]) / 2; j++) { chk[sum - j - a[i] - j] += dp[j] > 0; } for (int j = sum; j >= a[i]; j--) { add(dp[j], dp[j - a[i]]); } } vector<int> res; for (int i = 0; i <= sum; i++) if (chk[i] == n) res.pb(i); cout << res.size() << '\n'; for (int id : res) cout << id << ' '; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(task".INP","r")) { freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } Input(); Solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 280 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 280 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 356 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 5 ms | 364 KB | Output is correct |
25 | Correct | 6 ms | 340 KB | Output is correct |
26 | Correct | 7 ms | 404 KB | Output is correct |
27 | Correct | 5 ms | 372 KB | Output is correct |
28 | Correct | 5 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 340 KB | Output is correct |
31 | Correct | 8 ms | 340 KB | Output is correct |
32 | Correct | 6 ms | 360 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 6 ms | 408 KB | Output is correct |
36 | Correct | 5 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 280 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 356 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 5 ms | 364 KB | Output is correct |
25 | Correct | 6 ms | 340 KB | Output is correct |
26 | Correct | 7 ms | 404 KB | Output is correct |
27 | Correct | 5 ms | 372 KB | Output is correct |
28 | Correct | 5 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 340 KB | Output is correct |
31 | Correct | 8 ms | 340 KB | Output is correct |
32 | Correct | 6 ms | 360 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 6 ms | 408 KB | Output is correct |
36 | Correct | 5 ms | 340 KB | Output is correct |
37 | Correct | 38 ms | 600 KB | Output is correct |
38 | Correct | 37 ms | 604 KB | Output is correct |
39 | Correct | 53 ms | 848 KB | Output is correct |
40 | Correct | 83 ms | 696 KB | Output is correct |
41 | Correct | 65 ms | 876 KB | Output is correct |
42 | Correct | 71 ms | 704 KB | Output is correct |
43 | Correct | 131 ms | 1056 KB | Output is correct |
44 | Correct | 128 ms | 1040 KB | Output is correct |
45 | Correct | 133 ms | 1140 KB | Output is correct |
46 | Correct | 52 ms | 468 KB | Output is correct |
47 | Correct | 77 ms | 692 KB | Output is correct |
48 | Correct | 130 ms | 1076 KB | Output is correct |
49 | Correct | 94 ms | 792 KB | Output is correct |
50 | Correct | 80 ms | 700 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 163 ms | 1240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 280 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 356 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 5 ms | 364 KB | Output is correct |
25 | Correct | 6 ms | 340 KB | Output is correct |
26 | Correct | 7 ms | 404 KB | Output is correct |
27 | Correct | 5 ms | 372 KB | Output is correct |
28 | Correct | 5 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 340 KB | Output is correct |
31 | Correct | 8 ms | 340 KB | Output is correct |
32 | Correct | 6 ms | 360 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 6 ms | 408 KB | Output is correct |
36 | Correct | 5 ms | 340 KB | Output is correct |
37 | Correct | 38 ms | 600 KB | Output is correct |
38 | Correct | 37 ms | 604 KB | Output is correct |
39 | Correct | 53 ms | 848 KB | Output is correct |
40 | Correct | 83 ms | 696 KB | Output is correct |
41 | Correct | 65 ms | 876 KB | Output is correct |
42 | Correct | 71 ms | 704 KB | Output is correct |
43 | Correct | 131 ms | 1056 KB | Output is correct |
44 | Correct | 128 ms | 1040 KB | Output is correct |
45 | Correct | 133 ms | 1140 KB | Output is correct |
46 | Correct | 52 ms | 468 KB | Output is correct |
47 | Correct | 77 ms | 692 KB | Output is correct |
48 | Correct | 130 ms | 1076 KB | Output is correct |
49 | Correct | 94 ms | 792 KB | Output is correct |
50 | Correct | 80 ms | 700 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 163 ms | 1240 KB | Output is correct |
53 | Correct | 130 ms | 920 KB | Output is correct |
54 | Correct | 186 ms | 1132 KB | Output is correct |
55 | Correct | 346 ms | 1772 KB | Output is correct |
56 | Correct | 160 ms | 1036 KB | Output is correct |
57 | Correct | 366 ms | 1924 KB | Output is correct |
58 | Correct | 206 ms | 1192 KB | Output is correct |
59 | Correct | 253 ms | 1360 KB | Output is correct |
60 | Correct | 0 ms | 212 KB | Output is correct |
61 | Correct | 307 ms | 1616 KB | Output is correct |
62 | Correct | 292 ms | 1596 KB | Output is correct |
63 | Correct | 313 ms | 1636 KB | Output is correct |
64 | Correct | 300 ms | 1612 KB | Output is correct |
65 | Correct | 61 ms | 692 KB | Output is correct |
66 | Correct | 76 ms | 724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 280 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 356 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 5 ms | 364 KB | Output is correct |
25 | Correct | 6 ms | 340 KB | Output is correct |
26 | Correct | 7 ms | 404 KB | Output is correct |
27 | Correct | 5 ms | 372 KB | Output is correct |
28 | Correct | 5 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 340 KB | Output is correct |
31 | Correct | 8 ms | 340 KB | Output is correct |
32 | Correct | 6 ms | 360 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 6 ms | 408 KB | Output is correct |
36 | Correct | 5 ms | 340 KB | Output is correct |
37 | Correct | 38 ms | 600 KB | Output is correct |
38 | Correct | 37 ms | 604 KB | Output is correct |
39 | Correct | 53 ms | 848 KB | Output is correct |
40 | Correct | 83 ms | 696 KB | Output is correct |
41 | Correct | 65 ms | 876 KB | Output is correct |
42 | Correct | 71 ms | 704 KB | Output is correct |
43 | Correct | 131 ms | 1056 KB | Output is correct |
44 | Correct | 128 ms | 1040 KB | Output is correct |
45 | Correct | 133 ms | 1140 KB | Output is correct |
46 | Correct | 52 ms | 468 KB | Output is correct |
47 | Correct | 77 ms | 692 KB | Output is correct |
48 | Correct | 130 ms | 1076 KB | Output is correct |
49 | Correct | 94 ms | 792 KB | Output is correct |
50 | Correct | 80 ms | 700 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 163 ms | 1240 KB | Output is correct |
53 | Correct | 130 ms | 920 KB | Output is correct |
54 | Correct | 186 ms | 1132 KB | Output is correct |
55 | Correct | 346 ms | 1772 KB | Output is correct |
56 | Correct | 160 ms | 1036 KB | Output is correct |
57 | Correct | 366 ms | 1924 KB | Output is correct |
58 | Correct | 206 ms | 1192 KB | Output is correct |
59 | Correct | 253 ms | 1360 KB | Output is correct |
60 | Correct | 0 ms | 212 KB | Output is correct |
61 | Correct | 307 ms | 1616 KB | Output is correct |
62 | Correct | 292 ms | 1596 KB | Output is correct |
63 | Correct | 313 ms | 1636 KB | Output is correct |
64 | Correct | 300 ms | 1612 KB | Output is correct |
65 | Correct | 61 ms | 692 KB | Output is correct |
66 | Correct | 76 ms | 724 KB | Output is correct |
67 | Correct | 284 ms | 1520 KB | Output is correct |
68 | Correct | 114 ms | 788 KB | Output is correct |
69 | Correct | 991 ms | 3116 KB | Output is correct |
70 | Correct | 660 ms | 2088 KB | Output is correct |
71 | Correct | 616 ms | 2084 KB | Output is correct |
72 | Correct | 626 ms | 1308 KB | Output is correct |
73 | Correct | 647 ms | 1292 KB | Output is correct |
74 | Execution timed out | 1074 ms | 1956 KB | Time limit exceeded |
75 | Halted | 0 ms | 0 KB | - |