Submission #726425

# Submission time Handle Problem Language Result Execution time Memory
726425 2023-04-18T21:55:36 Z stevancv Bootfall (IZhO17_bootfall) C++14
100 / 100
981 ms 4520 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 500 + 2;
const int mod = 1e9 + 7;
int a[N], cnt[N * N], dp92[N * N], dpc[N * N];
int Add(int a, int b) {
    a += b;
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    int sum = 0;
    dp92[0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        for (int j = sum; j >= a[i]; j--) {
            dp92[j] = Add(dp92[j], dp92[j - a[i]]);
        }
    }
    if (sum % 2 == 1 || dp92[sum / 2] == 0) {
        cout << 0 << en;
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < a[i]; j++) dpc[j] = dp92[j];
        for (int j = a[i]; j <= sum; j++) dpc[j] = Add(dp92[j], -dpc[j - a[i]]);
        for (int j = 0; j <= sum; j++) {
            int x = 2 * j + a[i] - sum;
            if (dpc[j] > 0 && x > 0) cnt[x] += 1;
        }
    }
    vector<int> ans;
    for (int i = 1; i <= sum; i++) if (cnt[i] == n) ans.push_back(i);
    cout << ans.size() << en;
    for (int i : ans) cout << i << sp;
    cout << en;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 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 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 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 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 6 ms 492 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 5 ms 468 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 468 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 4 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 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 6 ms 492 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 5 ms 468 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 468 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 32 ms 688 KB Output is correct
38 Correct 35 ms 704 KB Output is correct
39 Correct 29 ms 980 KB Output is correct
40 Correct 86 ms 832 KB Output is correct
41 Correct 42 ms 1192 KB Output is correct
42 Correct 64 ms 796 KB Output is correct
43 Correct 109 ms 1356 KB Output is correct
44 Correct 121 ms 1372 KB Output is correct
45 Correct 125 ms 1280 KB Output is correct
46 Correct 45 ms 716 KB Output is correct
47 Correct 70 ms 832 KB Output is correct
48 Correct 100 ms 1356 KB Output is correct
49 Correct 71 ms 1064 KB Output is correct
50 Correct 73 ms 832 KB Output is correct
51 Correct 19 ms 372 KB Output is correct
52 Correct 147 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 6 ms 492 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 5 ms 468 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 468 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 32 ms 688 KB Output is correct
38 Correct 35 ms 704 KB Output is correct
39 Correct 29 ms 980 KB Output is correct
40 Correct 86 ms 832 KB Output is correct
41 Correct 42 ms 1192 KB Output is correct
42 Correct 64 ms 796 KB Output is correct
43 Correct 109 ms 1356 KB Output is correct
44 Correct 121 ms 1372 KB Output is correct
45 Correct 125 ms 1280 KB Output is correct
46 Correct 45 ms 716 KB Output is correct
47 Correct 70 ms 832 KB Output is correct
48 Correct 100 ms 1356 KB Output is correct
49 Correct 71 ms 1064 KB Output is correct
50 Correct 73 ms 832 KB Output is correct
51 Correct 19 ms 372 KB Output is correct
52 Correct 147 ms 1516 KB Output is correct
53 Correct 116 ms 1100 KB Output is correct
54 Correct 171 ms 1356 KB Output is correct
55 Correct 306 ms 2132 KB Output is correct
56 Correct 146 ms 1352 KB Output is correct
57 Correct 328 ms 2448 KB Output is correct
58 Correct 187 ms 1356 KB Output is correct
59 Correct 227 ms 1600 KB Output is correct
60 Correct 53 ms 672 KB Output is correct
61 Correct 252 ms 1844 KB Output is correct
62 Correct 257 ms 1952 KB Output is correct
63 Correct 273 ms 2140 KB Output is correct
64 Correct 271 ms 2044 KB Output is correct
65 Correct 39 ms 888 KB Output is correct
66 Correct 53 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 6 ms 492 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 4 ms 348 KB Output is correct
28 Correct 5 ms 468 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 468 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 4 ms 340 KB Output is correct
36 Correct 4 ms 340 KB Output is correct
37 Correct 32 ms 688 KB Output is correct
38 Correct 35 ms 704 KB Output is correct
39 Correct 29 ms 980 KB Output is correct
40 Correct 86 ms 832 KB Output is correct
41 Correct 42 ms 1192 KB Output is correct
42 Correct 64 ms 796 KB Output is correct
43 Correct 109 ms 1356 KB Output is correct
44 Correct 121 ms 1372 KB Output is correct
45 Correct 125 ms 1280 KB Output is correct
46 Correct 45 ms 716 KB Output is correct
47 Correct 70 ms 832 KB Output is correct
48 Correct 100 ms 1356 KB Output is correct
49 Correct 71 ms 1064 KB Output is correct
50 Correct 73 ms 832 KB Output is correct
51 Correct 19 ms 372 KB Output is correct
52 Correct 147 ms 1516 KB Output is correct
53 Correct 116 ms 1100 KB Output is correct
54 Correct 171 ms 1356 KB Output is correct
55 Correct 306 ms 2132 KB Output is correct
56 Correct 146 ms 1352 KB Output is correct
57 Correct 328 ms 2448 KB Output is correct
58 Correct 187 ms 1356 KB Output is correct
59 Correct 227 ms 1600 KB Output is correct
60 Correct 53 ms 672 KB Output is correct
61 Correct 252 ms 1844 KB Output is correct
62 Correct 257 ms 1952 KB Output is correct
63 Correct 273 ms 2140 KB Output is correct
64 Correct 271 ms 2044 KB Output is correct
65 Correct 39 ms 888 KB Output is correct
66 Correct 53 ms 948 KB Output is correct
67 Correct 245 ms 1768 KB Output is correct
68 Correct 88 ms 716 KB Output is correct
69 Correct 893 ms 3952 KB Output is correct
70 Correct 550 ms 2628 KB Output is correct
71 Correct 530 ms 2512 KB Output is correct
72 Correct 543 ms 1780 KB Output is correct
73 Correct 544 ms 1880 KB Output is correct
74 Correct 926 ms 4092 KB Output is correct
75 Correct 744 ms 3420 KB Output is correct
76 Correct 941 ms 4336 KB Output is correct
77 Correct 981 ms 4520 KB Output is correct