답안 #835710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835710 2023-08-23T17:55:22 Z vjudge1 Bootfall (IZhO17_bootfall) C++17
100 / 100
343 ms 4320 KB
#include <bits/stdc++.h>
using namespace std;

/// 123
int32_t main() {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        int sum = accumulate(a.begin(), a.end(), 0);
        vector<int64_t> f(sum + 1, 0);
        f[0] = 1;
        for (int i = 0; i < n; i++) {
                for (int j = sum; j >= a[i]; j--) {
                        f[j] += f[j - a[i]];
                }
        }

        if (sum % 2 || f[sum / 2] == 0) {
                return cout << 0, 0;
        }
        vector<int> good(sum + 1, 1);

        for (int i = 0; i < n; i++) {
                for (int j = a[i]; j <= sum; j++) {
                        f[j] -= f[j - a[i]];
                }
                for (int j = 0; j <= sum; j++) {
                        good[j] &= ((j + sum - a[i]) % 2 == 0) && (f[(j + sum - a[i]) / 2]);
                }
                for (int j = sum; j >= a[i]; j--) {
                        f[j] += f[j - a[i]];
                }
        }

        vector<int> ans;
        for (int i = 1; i <= sum; i++) {
                if (good[i]) ans.emplace_back(i);
        }
        cout << ans.size() << '\n';
        for (int i : ans) cout << i << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 296 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 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 296 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 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 432 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 424 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 296 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 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 432 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 424 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 11 ms 688 KB Output is correct
38 Correct 11 ms 688 KB Output is correct
39 Correct 40 ms 1020 KB Output is correct
40 Correct 25 ms 820 KB Output is correct
41 Correct 56 ms 1148 KB Output is correct
42 Correct 21 ms 800 KB Output is correct
43 Correct 36 ms 1212 KB Output is correct
44 Correct 43 ms 1316 KB Output is correct
45 Correct 43 ms 1220 KB Output is correct
46 Correct 23 ms 684 KB Output is correct
47 Correct 23 ms 800 KB Output is correct
48 Correct 42 ms 1280 KB Output is correct
49 Correct 40 ms 1032 KB Output is correct
50 Correct 23 ms 812 KB Output is correct
51 Correct 4 ms 468 KB Output is correct
52 Correct 59 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 296 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 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 432 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 424 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 11 ms 688 KB Output is correct
38 Correct 11 ms 688 KB Output is correct
39 Correct 40 ms 1020 KB Output is correct
40 Correct 25 ms 820 KB Output is correct
41 Correct 56 ms 1148 KB Output is correct
42 Correct 21 ms 800 KB Output is correct
43 Correct 36 ms 1212 KB Output is correct
44 Correct 43 ms 1316 KB Output is correct
45 Correct 43 ms 1220 KB Output is correct
46 Correct 23 ms 684 KB Output is correct
47 Correct 23 ms 800 KB Output is correct
48 Correct 42 ms 1280 KB Output is correct
49 Correct 40 ms 1032 KB Output is correct
50 Correct 23 ms 812 KB Output is correct
51 Correct 4 ms 468 KB Output is correct
52 Correct 59 ms 1516 KB Output is correct
53 Correct 36 ms 1100 KB Output is correct
54 Correct 52 ms 1344 KB Output is correct
55 Correct 105 ms 2116 KB Output is correct
56 Correct 46 ms 1340 KB Output is correct
57 Correct 111 ms 2308 KB Output is correct
58 Correct 59 ms 1400 KB Output is correct
59 Correct 70 ms 1572 KB Output is correct
60 Correct 10 ms 792 KB Output is correct
61 Correct 82 ms 1736 KB Output is correct
62 Correct 80 ms 1924 KB Output is correct
63 Correct 104 ms 2020 KB Output is correct
64 Correct 85 ms 2012 KB Output is correct
65 Correct 38 ms 816 KB Output is correct
66 Correct 41 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 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 296 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 296 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 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 3 ms 432 KB Output is correct
26 Correct 3 ms 340 KB Output is correct
27 Correct 3 ms 424 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 428 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 296 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 11 ms 688 KB Output is correct
38 Correct 11 ms 688 KB Output is correct
39 Correct 40 ms 1020 KB Output is correct
40 Correct 25 ms 820 KB Output is correct
41 Correct 56 ms 1148 KB Output is correct
42 Correct 21 ms 800 KB Output is correct
43 Correct 36 ms 1212 KB Output is correct
44 Correct 43 ms 1316 KB Output is correct
45 Correct 43 ms 1220 KB Output is correct
46 Correct 23 ms 684 KB Output is correct
47 Correct 23 ms 800 KB Output is correct
48 Correct 42 ms 1280 KB Output is correct
49 Correct 40 ms 1032 KB Output is correct
50 Correct 23 ms 812 KB Output is correct
51 Correct 4 ms 468 KB Output is correct
52 Correct 59 ms 1516 KB Output is correct
53 Correct 36 ms 1100 KB Output is correct
54 Correct 52 ms 1344 KB Output is correct
55 Correct 105 ms 2116 KB Output is correct
56 Correct 46 ms 1340 KB Output is correct
57 Correct 111 ms 2308 KB Output is correct
58 Correct 59 ms 1400 KB Output is correct
59 Correct 70 ms 1572 KB Output is correct
60 Correct 10 ms 792 KB Output is correct
61 Correct 82 ms 1736 KB Output is correct
62 Correct 80 ms 1924 KB Output is correct
63 Correct 104 ms 2020 KB Output is correct
64 Correct 85 ms 2012 KB Output is correct
65 Correct 38 ms 816 KB Output is correct
66 Correct 41 ms 912 KB Output is correct
67 Correct 84 ms 1744 KB Output is correct
68 Correct 28 ms 1268 KB Output is correct
69 Correct 319 ms 3924 KB Output is correct
70 Correct 177 ms 2460 KB Output is correct
71 Correct 168 ms 2388 KB Output is correct
72 Correct 164 ms 1668 KB Output is correct
73 Correct 193 ms 1760 KB Output is correct
74 Correct 297 ms 4100 KB Output is correct
75 Correct 227 ms 3324 KB Output is correct
76 Correct 343 ms 4312 KB Output is correct
77 Correct 341 ms 4320 KB Output is correct