Submission #726423

# Submission time Handle Problem Language Result Execution time Memory
726423 2023-04-18T21:51:28 Z stevancv Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 1904 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);
    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 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 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 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 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 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 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 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 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 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 10 ms 340 KB Output is correct
27 Correct 7 ms 396 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 8 ms 340 KB Output is correct
30 Correct 7 ms 340 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 7 ms 340 KB Output is correct
33 Correct 4 ms 412 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 8 ms 340 KB Output is correct
36 Correct 7 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 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 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 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 10 ms 340 KB Output is correct
27 Correct 7 ms 396 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 8 ms 340 KB Output is correct
30 Correct 7 ms 340 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 7 ms 340 KB Output is correct
33 Correct 4 ms 412 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 8 ms 340 KB Output is correct
36 Correct 7 ms 340 KB Output is correct
37 Correct 55 ms 596 KB Output is correct
38 Correct 57 ms 608 KB Output is correct
39 Correct 54 ms 792 KB Output is correct
40 Correct 126 ms 692 KB Output is correct
41 Correct 71 ms 972 KB Output is correct
42 Correct 109 ms 668 KB Output is correct
43 Correct 186 ms 1036 KB Output is correct
44 Correct 191 ms 1104 KB Output is correct
45 Correct 196 ms 1048 KB Output is correct
46 Correct 76 ms 468 KB Output is correct
47 Correct 116 ms 696 KB Output is correct
48 Correct 172 ms 1068 KB Output is correct
49 Correct 128 ms 792 KB Output is correct
50 Correct 118 ms 792 KB Output is correct
51 Correct 25 ms 340 KB Output is correct
52 Correct 245 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 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 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 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 10 ms 340 KB Output is correct
27 Correct 7 ms 396 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 8 ms 340 KB Output is correct
30 Correct 7 ms 340 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 7 ms 340 KB Output is correct
33 Correct 4 ms 412 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 8 ms 340 KB Output is correct
36 Correct 7 ms 340 KB Output is correct
37 Correct 55 ms 596 KB Output is correct
38 Correct 57 ms 608 KB Output is correct
39 Correct 54 ms 792 KB Output is correct
40 Correct 126 ms 692 KB Output is correct
41 Correct 71 ms 972 KB Output is correct
42 Correct 109 ms 668 KB Output is correct
43 Correct 186 ms 1036 KB Output is correct
44 Correct 191 ms 1104 KB Output is correct
45 Correct 196 ms 1048 KB Output is correct
46 Correct 76 ms 468 KB Output is correct
47 Correct 116 ms 696 KB Output is correct
48 Correct 172 ms 1068 KB Output is correct
49 Correct 128 ms 792 KB Output is correct
50 Correct 118 ms 792 KB Output is correct
51 Correct 25 ms 340 KB Output is correct
52 Correct 245 ms 1240 KB Output is correct
53 Correct 196 ms 1008 KB Output is correct
54 Correct 280 ms 1128 KB Output is correct
55 Correct 525 ms 1768 KB Output is correct
56 Correct 247 ms 1232 KB Output is correct
57 Correct 554 ms 1872 KB Output is correct
58 Correct 306 ms 1228 KB Output is correct
59 Correct 375 ms 1380 KB Output is correct
60 Correct 69 ms 552 KB Output is correct
61 Correct 423 ms 1512 KB Output is correct
62 Correct 439 ms 1616 KB Output is correct
63 Correct 458 ms 1740 KB Output is correct
64 Correct 446 ms 1624 KB Output is correct
65 Correct 69 ms 684 KB Output is correct
66 Correct 96 ms 788 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 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 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 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 10 ms 340 KB Output is correct
27 Correct 7 ms 396 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 8 ms 340 KB Output is correct
30 Correct 7 ms 340 KB Output is correct
31 Correct 10 ms 340 KB Output is correct
32 Correct 7 ms 340 KB Output is correct
33 Correct 4 ms 412 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 8 ms 340 KB Output is correct
36 Correct 7 ms 340 KB Output is correct
37 Correct 55 ms 596 KB Output is correct
38 Correct 57 ms 608 KB Output is correct
39 Correct 54 ms 792 KB Output is correct
40 Correct 126 ms 692 KB Output is correct
41 Correct 71 ms 972 KB Output is correct
42 Correct 109 ms 668 KB Output is correct
43 Correct 186 ms 1036 KB Output is correct
44 Correct 191 ms 1104 KB Output is correct
45 Correct 196 ms 1048 KB Output is correct
46 Correct 76 ms 468 KB Output is correct
47 Correct 116 ms 696 KB Output is correct
48 Correct 172 ms 1068 KB Output is correct
49 Correct 128 ms 792 KB Output is correct
50 Correct 118 ms 792 KB Output is correct
51 Correct 25 ms 340 KB Output is correct
52 Correct 245 ms 1240 KB Output is correct
53 Correct 196 ms 1008 KB Output is correct
54 Correct 280 ms 1128 KB Output is correct
55 Correct 525 ms 1768 KB Output is correct
56 Correct 247 ms 1232 KB Output is correct
57 Correct 554 ms 1872 KB Output is correct
58 Correct 306 ms 1228 KB Output is correct
59 Correct 375 ms 1380 KB Output is correct
60 Correct 69 ms 552 KB Output is correct
61 Correct 423 ms 1512 KB Output is correct
62 Correct 439 ms 1616 KB Output is correct
63 Correct 458 ms 1740 KB Output is correct
64 Correct 446 ms 1624 KB Output is correct
65 Correct 69 ms 684 KB Output is correct
66 Correct 96 ms 788 KB Output is correct
67 Correct 436 ms 1464 KB Output is correct
68 Correct 137 ms 724 KB Output is correct
69 Execution timed out 1097 ms 1904 KB Time limit exceeded
70 Halted 0 ms 0 KB -