Submission #1022428

# Submission time Handle Problem Language Result Execution time Memory
1022428 2024-07-13T13:30:36 Z phoenix Bootfall (IZhO17_bootfall) C++17
100 / 100
270 ms 3560 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 550;
const int A = 250250;
 
int lim = 0;
unsigned int dp[A]{1};

int sum = 0;
 
void add(int val) {
    sum += val;
    for (int i = lim; i >= val; i--) {
        dp[i] += dp[i - val];
    }   
}
 
bool check(int sum) {
    if (sum < 0 && sum > lim) return 0;
    return (dp[sum]);
}
 
void del(int val) {
    sum -= val;
    for (int i = val; i <= lim; i++) {
        dp[i] -= dp[i - val];
    }
}
 
int n;
int a[N];
int cnt[A];
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        lim += a[i];
    }
    for (int i = 0; i < n; i++) {
        add(a[i]);
    }
    if (sum & 1 || !check(sum / 2)) {
        cout << 0;
        return 0;
    }
 
    for (int i = 0; i < n; i++) {
        if (i) add(a[i - 1]);
        del(a[i]);
        for (int s = 0; s <= lim; s++) {
            if (check(s)) {
                cnt[abs(2 * s - sum)]++;
            }
        }
    }
    vector<int> res;
    for (int i = 1; i <= lim; i++) {
        if (cnt[i] == 2 * n) 
            res.push_back(i);
    }
    cout << (int)res.size() << '\n';
    for (int c : res) cout << c << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 476 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 472 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 476 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 472 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 9 ms 872 KB Output is correct
38 Correct 9 ms 628 KB Output is correct
39 Correct 30 ms 860 KB Output is correct
40 Correct 20 ms 860 KB Output is correct
41 Correct 38 ms 1016 KB Output is correct
42 Correct 17 ms 860 KB Output is correct
43 Correct 30 ms 1152 KB Output is correct
44 Correct 33 ms 1156 KB Output is correct
45 Correct 43 ms 1104 KB Output is correct
46 Correct 17 ms 712 KB Output is correct
47 Correct 18 ms 860 KB Output is correct
48 Correct 33 ms 1104 KB Output is correct
49 Correct 33 ms 948 KB Output is correct
50 Correct 19 ms 900 KB Output is correct
51 Correct 4 ms 348 KB Output is correct
52 Correct 46 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 476 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 472 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 9 ms 872 KB Output is correct
38 Correct 9 ms 628 KB Output is correct
39 Correct 30 ms 860 KB Output is correct
40 Correct 20 ms 860 KB Output is correct
41 Correct 38 ms 1016 KB Output is correct
42 Correct 17 ms 860 KB Output is correct
43 Correct 30 ms 1152 KB Output is correct
44 Correct 33 ms 1156 KB Output is correct
45 Correct 43 ms 1104 KB Output is correct
46 Correct 17 ms 712 KB Output is correct
47 Correct 18 ms 860 KB Output is correct
48 Correct 33 ms 1104 KB Output is correct
49 Correct 33 ms 948 KB Output is correct
50 Correct 19 ms 900 KB Output is correct
51 Correct 4 ms 348 KB Output is correct
52 Correct 46 ms 1252 KB Output is correct
53 Correct 30 ms 1152 KB Output is correct
54 Correct 42 ms 1112 KB Output is correct
55 Correct 82 ms 1716 KB Output is correct
56 Correct 36 ms 1148 KB Output is correct
57 Correct 87 ms 2004 KB Output is correct
58 Correct 46 ms 1112 KB Output is correct
59 Correct 58 ms 1496 KB Output is correct
60 Correct 9 ms 600 KB Output is correct
61 Correct 66 ms 1520 KB Output is correct
62 Correct 66 ms 1748 KB Output is correct
63 Correct 71 ms 1748 KB Output is correct
64 Correct 68 ms 1752 KB Output is correct
65 Correct 31 ms 832 KB Output is correct
66 Correct 34 ms 872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 476 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 472 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 9 ms 872 KB Output is correct
38 Correct 9 ms 628 KB Output is correct
39 Correct 30 ms 860 KB Output is correct
40 Correct 20 ms 860 KB Output is correct
41 Correct 38 ms 1016 KB Output is correct
42 Correct 17 ms 860 KB Output is correct
43 Correct 30 ms 1152 KB Output is correct
44 Correct 33 ms 1156 KB Output is correct
45 Correct 43 ms 1104 KB Output is correct
46 Correct 17 ms 712 KB Output is correct
47 Correct 18 ms 860 KB Output is correct
48 Correct 33 ms 1104 KB Output is correct
49 Correct 33 ms 948 KB Output is correct
50 Correct 19 ms 900 KB Output is correct
51 Correct 4 ms 348 KB Output is correct
52 Correct 46 ms 1252 KB Output is correct
53 Correct 30 ms 1152 KB Output is correct
54 Correct 42 ms 1112 KB Output is correct
55 Correct 82 ms 1716 KB Output is correct
56 Correct 36 ms 1148 KB Output is correct
57 Correct 87 ms 2004 KB Output is correct
58 Correct 46 ms 1112 KB Output is correct
59 Correct 58 ms 1496 KB Output is correct
60 Correct 9 ms 600 KB Output is correct
61 Correct 66 ms 1520 KB Output is correct
62 Correct 66 ms 1748 KB Output is correct
63 Correct 71 ms 1748 KB Output is correct
64 Correct 68 ms 1752 KB Output is correct
65 Correct 31 ms 832 KB Output is correct
66 Correct 34 ms 872 KB Output is correct
67 Correct 68 ms 1420 KB Output is correct
68 Correct 25 ms 860 KB Output is correct
69 Correct 228 ms 3284 KB Output is correct
70 Correct 146 ms 2008 KB Output is correct
71 Correct 132 ms 2068 KB Output is correct
72 Correct 127 ms 1372 KB Output is correct
73 Correct 127 ms 1424 KB Output is correct
74 Correct 247 ms 3280 KB Output is correct
75 Correct 178 ms 2772 KB Output is correct
76 Correct 270 ms 3508 KB Output is correct
77 Correct 253 ms 3560 KB Output is correct