Submission #915047

# Submission time Handle Problem Language Result Execution time Memory
915047 2024-01-23T08:44:50 Z adaawf Bootfall (IZhO17_bootfall) C++17
100 / 100
560 ms 4176 KB
#include <iostream>
using namespace std;
int a[505], f[250005], g[250005], dd[250005], mod = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, c = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        c += a[i];
    }
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= c; j++) {
            g[j] = f[j];
            f[j] = 0;
        }
        for (int j = 0; j <= c - a[i]; j++) {
            if (g[j] != 0) {
                f[j] += g[j];
                f[j + a[i]] += g[j];
                if (f[j] >= mod) f[j] -= mod;
            }
        }
    }
    if (c % 2 != 0 || f[c / 2] == 0) {
        cout << 0;
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= c; j++) {
            g[j] = f[j];
        }
        for (int j = a[i]; j <= c; j++) {
            g[j] -= g[j - a[i]];
            if (g[j] < 0) g[j] += mod;
        }
        int h = c - a[i];
        for (int j = 0; j <= c; j++) {
            if (h - j < 0 || h % 2 != j % 2 || g[(h - j) / 2] == 0) {
                dd[j] = 1;
            }
        }
    }
    int res = 0;
    for (int i = 0; i <= c; i++) {
        if (dd[i] == 0) {
            res++;
        }
    }
    cout << res << '\n';
    for (int i = 0; i <= c; i++) {
        if (dd[i] == 0) {
            cout << i << " ";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 4 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 4 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 4 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 ms 2520 KB Output is correct
23 Correct 1 ms 2528 KB Output is correct
24 Correct 3 ms 2392 KB Output is correct
25 Correct 4 ms 2392 KB Output is correct
26 Correct 4 ms 2648 KB Output is correct
27 Correct 4 ms 2396 KB Output is correct
28 Correct 4 ms 2396 KB Output is correct
29 Correct 4 ms 2552 KB Output is correct
30 Correct 3 ms 2396 KB Output is correct
31 Correct 4 ms 2508 KB Output is correct
32 Correct 3 ms 2392 KB Output is correct
33 Correct 4 ms 2392 KB Output is correct
34 Correct 4 ms 2516 KB Output is correct
35 Correct 4 ms 2392 KB Output is correct
36 Correct 3 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 4 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 ms 2520 KB Output is correct
23 Correct 1 ms 2528 KB Output is correct
24 Correct 3 ms 2392 KB Output is correct
25 Correct 4 ms 2392 KB Output is correct
26 Correct 4 ms 2648 KB Output is correct
27 Correct 4 ms 2396 KB Output is correct
28 Correct 4 ms 2396 KB Output is correct
29 Correct 4 ms 2552 KB Output is correct
30 Correct 3 ms 2396 KB Output is correct
31 Correct 4 ms 2508 KB Output is correct
32 Correct 3 ms 2392 KB Output is correct
33 Correct 4 ms 2392 KB Output is correct
34 Correct 4 ms 2516 KB Output is correct
35 Correct 4 ms 2392 KB Output is correct
36 Correct 3 ms 2552 KB Output is correct
37 Correct 17 ms 2652 KB Output is correct
38 Correct 17 ms 2396 KB Output is correct
39 Correct 44 ms 2648 KB Output is correct
40 Correct 44 ms 2636 KB Output is correct
41 Correct 52 ms 2652 KB Output is correct
42 Correct 35 ms 2900 KB Output is correct
43 Correct 56 ms 2752 KB Output is correct
44 Correct 59 ms 2828 KB Output is correct
45 Correct 60 ms 2768 KB Output is correct
46 Correct 30 ms 2396 KB Output is correct
47 Correct 36 ms 2644 KB Output is correct
48 Correct 63 ms 2768 KB Output is correct
49 Correct 49 ms 2648 KB Output is correct
50 Correct 36 ms 2772 KB Output is correct
51 Correct 21 ms 2392 KB Output is correct
52 Correct 76 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 4 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 ms 2520 KB Output is correct
23 Correct 1 ms 2528 KB Output is correct
24 Correct 3 ms 2392 KB Output is correct
25 Correct 4 ms 2392 KB Output is correct
26 Correct 4 ms 2648 KB Output is correct
27 Correct 4 ms 2396 KB Output is correct
28 Correct 4 ms 2396 KB Output is correct
29 Correct 4 ms 2552 KB Output is correct
30 Correct 3 ms 2396 KB Output is correct
31 Correct 4 ms 2508 KB Output is correct
32 Correct 3 ms 2392 KB Output is correct
33 Correct 4 ms 2392 KB Output is correct
34 Correct 4 ms 2516 KB Output is correct
35 Correct 4 ms 2392 KB Output is correct
36 Correct 3 ms 2552 KB Output is correct
37 Correct 17 ms 2652 KB Output is correct
38 Correct 17 ms 2396 KB Output is correct
39 Correct 44 ms 2648 KB Output is correct
40 Correct 44 ms 2636 KB Output is correct
41 Correct 52 ms 2652 KB Output is correct
42 Correct 35 ms 2900 KB Output is correct
43 Correct 56 ms 2752 KB Output is correct
44 Correct 59 ms 2828 KB Output is correct
45 Correct 60 ms 2768 KB Output is correct
46 Correct 30 ms 2396 KB Output is correct
47 Correct 36 ms 2644 KB Output is correct
48 Correct 63 ms 2768 KB Output is correct
49 Correct 49 ms 2648 KB Output is correct
50 Correct 36 ms 2772 KB Output is correct
51 Correct 21 ms 2392 KB Output is correct
52 Correct 76 ms 2644 KB Output is correct
53 Correct 59 ms 2640 KB Output is correct
54 Correct 84 ms 2768 KB Output is correct
55 Correct 173 ms 2916 KB Output is correct
56 Correct 76 ms 2644 KB Output is correct
57 Correct 180 ms 2944 KB Output is correct
58 Correct 93 ms 2676 KB Output is correct
59 Correct 118 ms 2780 KB Output is correct
60 Correct 55 ms 2392 KB Output is correct
61 Correct 134 ms 2900 KB Output is correct
62 Correct 132 ms 2872 KB Output is correct
63 Correct 148 ms 2896 KB Output is correct
64 Correct 155 ms 3056 KB Output is correct
65 Correct 41 ms 2684 KB Output is correct
66 Correct 52 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 4 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 ms 2520 KB Output is correct
23 Correct 1 ms 2528 KB Output is correct
24 Correct 3 ms 2392 KB Output is correct
25 Correct 4 ms 2392 KB Output is correct
26 Correct 4 ms 2648 KB Output is correct
27 Correct 4 ms 2396 KB Output is correct
28 Correct 4 ms 2396 KB Output is correct
29 Correct 4 ms 2552 KB Output is correct
30 Correct 3 ms 2396 KB Output is correct
31 Correct 4 ms 2508 KB Output is correct
32 Correct 3 ms 2392 KB Output is correct
33 Correct 4 ms 2392 KB Output is correct
34 Correct 4 ms 2516 KB Output is correct
35 Correct 4 ms 2392 KB Output is correct
36 Correct 3 ms 2552 KB Output is correct
37 Correct 17 ms 2652 KB Output is correct
38 Correct 17 ms 2396 KB Output is correct
39 Correct 44 ms 2648 KB Output is correct
40 Correct 44 ms 2636 KB Output is correct
41 Correct 52 ms 2652 KB Output is correct
42 Correct 35 ms 2900 KB Output is correct
43 Correct 56 ms 2752 KB Output is correct
44 Correct 59 ms 2828 KB Output is correct
45 Correct 60 ms 2768 KB Output is correct
46 Correct 30 ms 2396 KB Output is correct
47 Correct 36 ms 2644 KB Output is correct
48 Correct 63 ms 2768 KB Output is correct
49 Correct 49 ms 2648 KB Output is correct
50 Correct 36 ms 2772 KB Output is correct
51 Correct 21 ms 2392 KB Output is correct
52 Correct 76 ms 2644 KB Output is correct
53 Correct 59 ms 2640 KB Output is correct
54 Correct 84 ms 2768 KB Output is correct
55 Correct 173 ms 2916 KB Output is correct
56 Correct 76 ms 2644 KB Output is correct
57 Correct 180 ms 2944 KB Output is correct
58 Correct 93 ms 2676 KB Output is correct
59 Correct 118 ms 2780 KB Output is correct
60 Correct 55 ms 2392 KB Output is correct
61 Correct 134 ms 2900 KB Output is correct
62 Correct 132 ms 2872 KB Output is correct
63 Correct 148 ms 2896 KB Output is correct
64 Correct 155 ms 3056 KB Output is correct
65 Correct 41 ms 2684 KB Output is correct
66 Correct 52 ms 2652 KB Output is correct
67 Correct 119 ms 2896 KB Output is correct
68 Correct 121 ms 2708 KB Output is correct
69 Correct 458 ms 3668 KB Output is correct
70 Correct 295 ms 3152 KB Output is correct
71 Correct 279 ms 3140 KB Output is correct
72 Correct 280 ms 2900 KB Output is correct
73 Correct 274 ms 2712 KB Output is correct
74 Correct 537 ms 3900 KB Output is correct
75 Correct 386 ms 3588 KB Output is correct
76 Correct 560 ms 4176 KB Output is correct
77 Correct 542 ms 3928 KB Output is correct