답안 #726424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
726424 2023-04-18T21:53:42 Z stevancv Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 4172 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;
    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 = 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 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 7 ms 484 KB Output is correct
26 Correct 7 ms 444 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 420 KB Output is correct
32 Correct 4 ms 392 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 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 7 ms 484 KB Output is correct
26 Correct 7 ms 444 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 420 KB Output is correct
32 Correct 4 ms 392 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
37 Correct 36 ms 660 KB Output is correct
38 Correct 36 ms 692 KB Output is correct
39 Correct 39 ms 1100 KB Output is correct
40 Correct 80 ms 956 KB Output is correct
41 Correct 50 ms 1132 KB Output is correct
42 Correct 74 ms 828 KB Output is correct
43 Correct 117 ms 1352 KB Output is correct
44 Correct 122 ms 1360 KB Output is correct
45 Correct 127 ms 1356 KB Output is correct
46 Correct 53 ms 696 KB Output is correct
47 Correct 77 ms 828 KB Output is correct
48 Correct 110 ms 1292 KB Output is correct
49 Correct 88 ms 1100 KB Output is correct
50 Correct 80 ms 840 KB Output is correct
51 Correct 25 ms 464 KB Output is correct
52 Correct 163 ms 1524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 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 7 ms 484 KB Output is correct
26 Correct 7 ms 444 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 420 KB Output is correct
32 Correct 4 ms 392 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
37 Correct 36 ms 660 KB Output is correct
38 Correct 36 ms 692 KB Output is correct
39 Correct 39 ms 1100 KB Output is correct
40 Correct 80 ms 956 KB Output is correct
41 Correct 50 ms 1132 KB Output is correct
42 Correct 74 ms 828 KB Output is correct
43 Correct 117 ms 1352 KB Output is correct
44 Correct 122 ms 1360 KB Output is correct
45 Correct 127 ms 1356 KB Output is correct
46 Correct 53 ms 696 KB Output is correct
47 Correct 77 ms 828 KB Output is correct
48 Correct 110 ms 1292 KB Output is correct
49 Correct 88 ms 1100 KB Output is correct
50 Correct 80 ms 840 KB Output is correct
51 Correct 25 ms 464 KB Output is correct
52 Correct 163 ms 1524 KB Output is correct
53 Correct 136 ms 1228 KB Output is correct
54 Correct 182 ms 1428 KB Output is correct
55 Correct 333 ms 2128 KB Output is correct
56 Correct 173 ms 1352 KB Output is correct
57 Correct 356 ms 2332 KB Output is correct
58 Correct 201 ms 1420 KB Output is correct
59 Correct 251 ms 1640 KB Output is correct
60 Correct 69 ms 468 KB Output is correct
61 Correct 309 ms 1844 KB Output is correct
62 Correct 275 ms 1956 KB Output is correct
63 Correct 332 ms 2044 KB Output is correct
64 Correct 283 ms 2036 KB Output is correct
65 Correct 57 ms 900 KB Output is correct
66 Correct 74 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 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 7 ms 484 KB Output is correct
26 Correct 7 ms 444 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 420 KB Output is correct
32 Correct 4 ms 392 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
37 Correct 36 ms 660 KB Output is correct
38 Correct 36 ms 692 KB Output is correct
39 Correct 39 ms 1100 KB Output is correct
40 Correct 80 ms 956 KB Output is correct
41 Correct 50 ms 1132 KB Output is correct
42 Correct 74 ms 828 KB Output is correct
43 Correct 117 ms 1352 KB Output is correct
44 Correct 122 ms 1360 KB Output is correct
45 Correct 127 ms 1356 KB Output is correct
46 Correct 53 ms 696 KB Output is correct
47 Correct 77 ms 828 KB Output is correct
48 Correct 110 ms 1292 KB Output is correct
49 Correct 88 ms 1100 KB Output is correct
50 Correct 80 ms 840 KB Output is correct
51 Correct 25 ms 464 KB Output is correct
52 Correct 163 ms 1524 KB Output is correct
53 Correct 136 ms 1228 KB Output is correct
54 Correct 182 ms 1428 KB Output is correct
55 Correct 333 ms 2128 KB Output is correct
56 Correct 173 ms 1352 KB Output is correct
57 Correct 356 ms 2332 KB Output is correct
58 Correct 201 ms 1420 KB Output is correct
59 Correct 251 ms 1640 KB Output is correct
60 Correct 69 ms 468 KB Output is correct
61 Correct 309 ms 1844 KB Output is correct
62 Correct 275 ms 1956 KB Output is correct
63 Correct 332 ms 2044 KB Output is correct
64 Correct 283 ms 2036 KB Output is correct
65 Correct 57 ms 900 KB Output is correct
66 Correct 74 ms 972 KB Output is correct
67 Correct 263 ms 1772 KB Output is correct
68 Correct 139 ms 792 KB Output is correct
69 Correct 956 ms 3956 KB Output is correct
70 Correct 607 ms 2612 KB Output is correct
71 Correct 591 ms 2544 KB Output is correct
72 Correct 620 ms 1788 KB Output is correct
73 Correct 558 ms 1844 KB Output is correct
74 Execution timed out 1000 ms 4172 KB Time limit exceeded
75 Halted 0 ms 0 KB -