Submission #726422

# Submission time Handle Problem Language Result Execution time Memory
726422 2023-04-18T21:50:31 Z stevancv Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 1920 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];
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;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    dp92[0] = 1;
    for (int i = 1; i <= n; 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 = a[i]; j <= sum; j++) dp92[j] = Add(dp92[j], -dp92[j - a[i]]);
        for (int j = 0; j <= sum; j++) {
            int x = 2 * j + a[i] - sum;
            if (dp92[j] > 0 && x > 0) cnt[x] += 1;
        }
        for (int j = sum; j >= a[i]; j--) dp92[j] = Add(dp92[j], dp92[j - a[i]]);
    }
    vector<int> ans;
    for (int i = 1; i <= sum; i++) if (cnt[i] == n) ans.push_back(i);
    sort(ans.begin(), ans.end());
    cout << ans.size() << en;
    for (int i : ans) cout << i << sp;
    cout << en;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 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 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 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 3 ms 332 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 12 ms 340 KB Output is correct
27 Correct 10 ms 336 KB Output is correct
28 Correct 9 ms 340 KB Output is correct
29 Correct 8 ms 332 KB Output is correct
30 Correct 7 ms 328 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 8 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 4 ms 332 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 7 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 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 3 ms 332 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 12 ms 340 KB Output is correct
27 Correct 10 ms 336 KB Output is correct
28 Correct 9 ms 340 KB Output is correct
29 Correct 8 ms 332 KB Output is correct
30 Correct 7 ms 328 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 8 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 4 ms 332 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 7 ms 324 KB Output is correct
37 Correct 57 ms 592 KB Output is correct
38 Correct 57 ms 572 KB Output is correct
39 Correct 50 ms 792 KB Output is correct
40 Correct 129 ms 700 KB Output is correct
41 Correct 69 ms 884 KB Output is correct
42 Correct 108 ms 680 KB Output is correct
43 Correct 197 ms 1044 KB Output is correct
44 Correct 195 ms 1140 KB Output is correct
45 Correct 195 ms 1200 KB Output is correct
46 Correct 77 ms 452 KB Output is correct
47 Correct 122 ms 700 KB Output is correct
48 Correct 178 ms 1076 KB Output is correct
49 Correct 129 ms 792 KB Output is correct
50 Correct 118 ms 696 KB Output is correct
51 Correct 25 ms 464 KB Output is correct
52 Correct 253 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 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 3 ms 332 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 12 ms 340 KB Output is correct
27 Correct 10 ms 336 KB Output is correct
28 Correct 9 ms 340 KB Output is correct
29 Correct 8 ms 332 KB Output is correct
30 Correct 7 ms 328 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 8 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 4 ms 332 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 7 ms 324 KB Output is correct
37 Correct 57 ms 592 KB Output is correct
38 Correct 57 ms 572 KB Output is correct
39 Correct 50 ms 792 KB Output is correct
40 Correct 129 ms 700 KB Output is correct
41 Correct 69 ms 884 KB Output is correct
42 Correct 108 ms 680 KB Output is correct
43 Correct 197 ms 1044 KB Output is correct
44 Correct 195 ms 1140 KB Output is correct
45 Correct 195 ms 1200 KB Output is correct
46 Correct 77 ms 452 KB Output is correct
47 Correct 122 ms 700 KB Output is correct
48 Correct 178 ms 1076 KB Output is correct
49 Correct 129 ms 792 KB Output is correct
50 Correct 118 ms 696 KB Output is correct
51 Correct 25 ms 464 KB Output is correct
52 Correct 253 ms 1236 KB Output is correct
53 Correct 221 ms 1012 KB Output is correct
54 Correct 290 ms 1100 KB Output is correct
55 Correct 532 ms 1772 KB Output is correct
56 Correct 247 ms 1128 KB Output is correct
57 Correct 599 ms 1920 KB Output is correct
58 Correct 326 ms 1192 KB Output is correct
59 Correct 391 ms 1484 KB Output is correct
60 Correct 68 ms 468 KB Output is correct
61 Correct 434 ms 1496 KB Output is correct
62 Correct 433 ms 1584 KB Output is correct
63 Correct 470 ms 1628 KB Output is correct
64 Correct 448 ms 1632 KB Output is correct
65 Correct 68 ms 704 KB Output is correct
66 Correct 98 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 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 3 ms 332 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 12 ms 340 KB Output is correct
27 Correct 10 ms 336 KB Output is correct
28 Correct 9 ms 340 KB Output is correct
29 Correct 8 ms 332 KB Output is correct
30 Correct 7 ms 328 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 8 ms 340 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 4 ms 332 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 7 ms 324 KB Output is correct
37 Correct 57 ms 592 KB Output is correct
38 Correct 57 ms 572 KB Output is correct
39 Correct 50 ms 792 KB Output is correct
40 Correct 129 ms 700 KB Output is correct
41 Correct 69 ms 884 KB Output is correct
42 Correct 108 ms 680 KB Output is correct
43 Correct 197 ms 1044 KB Output is correct
44 Correct 195 ms 1140 KB Output is correct
45 Correct 195 ms 1200 KB Output is correct
46 Correct 77 ms 452 KB Output is correct
47 Correct 122 ms 700 KB Output is correct
48 Correct 178 ms 1076 KB Output is correct
49 Correct 129 ms 792 KB Output is correct
50 Correct 118 ms 696 KB Output is correct
51 Correct 25 ms 464 KB Output is correct
52 Correct 253 ms 1236 KB Output is correct
53 Correct 221 ms 1012 KB Output is correct
54 Correct 290 ms 1100 KB Output is correct
55 Correct 532 ms 1772 KB Output is correct
56 Correct 247 ms 1128 KB Output is correct
57 Correct 599 ms 1920 KB Output is correct
58 Correct 326 ms 1192 KB Output is correct
59 Correct 391 ms 1484 KB Output is correct
60 Correct 68 ms 468 KB Output is correct
61 Correct 434 ms 1496 KB Output is correct
62 Correct 433 ms 1584 KB Output is correct
63 Correct 470 ms 1628 KB Output is correct
64 Correct 448 ms 1632 KB Output is correct
65 Correct 68 ms 704 KB Output is correct
66 Correct 98 ms 736 KB Output is correct
67 Correct 444 ms 1532 KB Output is correct
68 Correct 138 ms 792 KB Output is correct
69 Execution timed out 1081 ms 1904 KB Time limit exceeded
70 Halted 0 ms 0 KB -