답안 #346815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
346815 2021-01-11T06:45:41 Z SeDunion Bootfall (IZhO17_bootfall) C++17
100 / 100
485 ms 3052 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 505;
const int MX = 500 * 500 + 5;

const int mod = 1e9 + 7;
int a[N], d[MX], cnt[MX], Sum;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	d[0] = 1;
	for (int i = 1 ; i <= n ; ++ i) {
		cin >> a[i];
		Sum += a[i];
		for (int j = MX - 1 ; j >= a[i] ; -- j) {
			d[j] += d[j - a[i]];
			d[j] -= d[j] >= mod ? mod : 0;
		}
	}
	if (Sum & 1 || !d[Sum / 2]) return cout << "0", 0;
	for (int i = 1 ; i <= n ; ++ i) {
		int Now = Sum - a[i];
		//cout << i << " " << Now << endl;
		for (int j = a[i] ; j < MX ; ++ j) {
			d[j] -= d[j - a[i]];
			d[j] += d[j] < 0 ? mod : 0;
		}
		for (int j = Now & 1 ; j < MX ; j += 2) {
			int Cur = Now + j;
			cnt[j] += j <= (Cur >> 1) && !!d[(Cur >> 1) - j];
		}
		for (int j = MX - 1 ; j >= a[i] ; -- j) {
			d[j] += d[j - a[i]];
			d[j] -= d[j] >= mod ? mod : 0;
		}
	}
	int Cnt = 0;
	for (int i = 0 ; i < MX ; ++ i) Cnt += cnt[i] == n;
	cout << Cnt << "\n";
	for (int i = 0 ; i < MX ; ++ i) if (cnt[i] == n) cout << i << " ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2304 KB Output is correct
2 Correct 8 ms 2284 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 6 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 8 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 11 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2304 KB Output is correct
2 Correct 8 ms 2284 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 6 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 8 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 11 ms 2284 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 32 ms 2284 KB Output is correct
12 Correct 30 ms 2284 KB Output is correct
13 Correct 29 ms 2412 KB Output is correct
14 Correct 28 ms 2284 KB Output is correct
15 Correct 30 ms 2284 KB Output is correct
16 Correct 33 ms 2284 KB Output is correct
17 Correct 19 ms 2284 KB Output is correct
18 Correct 25 ms 2284 KB Output is correct
19 Correct 27 ms 2284 KB Output is correct
20 Correct 29 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2304 KB Output is correct
2 Correct 8 ms 2284 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 6 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 8 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 11 ms 2284 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 32 ms 2284 KB Output is correct
12 Correct 30 ms 2284 KB Output is correct
13 Correct 29 ms 2412 KB Output is correct
14 Correct 28 ms 2284 KB Output is correct
15 Correct 30 ms 2284 KB Output is correct
16 Correct 33 ms 2284 KB Output is correct
17 Correct 19 ms 2284 KB Output is correct
18 Correct 25 ms 2284 KB Output is correct
19 Correct 27 ms 2284 KB Output is correct
20 Correct 29 ms 2284 KB Output is correct
21 Correct 60 ms 2284 KB Output is correct
22 Correct 69 ms 2284 KB Output is correct
23 Correct 48 ms 2284 KB Output is correct
24 Correct 90 ms 2284 KB Output is correct
25 Correct 89 ms 2284 KB Output is correct
26 Correct 91 ms 2284 KB Output is correct
27 Correct 94 ms 2284 KB Output is correct
28 Correct 90 ms 2284 KB Output is correct
29 Correct 92 ms 2284 KB Output is correct
30 Correct 92 ms 2284 KB Output is correct
31 Correct 91 ms 2284 KB Output is correct
32 Correct 95 ms 2284 KB Output is correct
33 Correct 91 ms 2284 KB Output is correct
34 Correct 92 ms 2284 KB Output is correct
35 Correct 91 ms 2284 KB Output is correct
36 Correct 94 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2304 KB Output is correct
2 Correct 8 ms 2284 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 6 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 8 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 11 ms 2284 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 32 ms 2284 KB Output is correct
12 Correct 30 ms 2284 KB Output is correct
13 Correct 29 ms 2412 KB Output is correct
14 Correct 28 ms 2284 KB Output is correct
15 Correct 30 ms 2284 KB Output is correct
16 Correct 33 ms 2284 KB Output is correct
17 Correct 19 ms 2284 KB Output is correct
18 Correct 25 ms 2284 KB Output is correct
19 Correct 27 ms 2284 KB Output is correct
20 Correct 29 ms 2284 KB Output is correct
21 Correct 60 ms 2284 KB Output is correct
22 Correct 69 ms 2284 KB Output is correct
23 Correct 48 ms 2284 KB Output is correct
24 Correct 90 ms 2284 KB Output is correct
25 Correct 89 ms 2284 KB Output is correct
26 Correct 91 ms 2284 KB Output is correct
27 Correct 94 ms 2284 KB Output is correct
28 Correct 90 ms 2284 KB Output is correct
29 Correct 92 ms 2284 KB Output is correct
30 Correct 92 ms 2284 KB Output is correct
31 Correct 91 ms 2284 KB Output is correct
32 Correct 95 ms 2284 KB Output is correct
33 Correct 91 ms 2284 KB Output is correct
34 Correct 92 ms 2284 KB Output is correct
35 Correct 91 ms 2284 KB Output is correct
36 Correct 94 ms 2284 KB Output is correct
37 Correct 181 ms 2360 KB Output is correct
38 Correct 181 ms 2432 KB Output is correct
39 Correct 224 ms 2284 KB Output is correct
40 Correct 247 ms 2412 KB Output is correct
41 Correct 247 ms 2412 KB Output is correct
42 Correct 226 ms 2412 KB Output is correct
43 Correct 225 ms 2540 KB Output is correct
44 Correct 230 ms 2412 KB Output is correct
45 Correct 229 ms 2540 KB Output is correct
46 Correct 247 ms 2284 KB Output is correct
47 Correct 229 ms 2412 KB Output is correct
48 Correct 227 ms 2412 KB Output is correct
49 Correct 228 ms 2284 KB Output is correct
50 Correct 234 ms 2412 KB Output is correct
51 Correct 69 ms 1388 KB Output is correct
52 Correct 250 ms 2540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2304 KB Output is correct
2 Correct 8 ms 2284 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 6 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 8 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 11 ms 2284 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 32 ms 2284 KB Output is correct
12 Correct 30 ms 2284 KB Output is correct
13 Correct 29 ms 2412 KB Output is correct
14 Correct 28 ms 2284 KB Output is correct
15 Correct 30 ms 2284 KB Output is correct
16 Correct 33 ms 2284 KB Output is correct
17 Correct 19 ms 2284 KB Output is correct
18 Correct 25 ms 2284 KB Output is correct
19 Correct 27 ms 2284 KB Output is correct
20 Correct 29 ms 2284 KB Output is correct
21 Correct 60 ms 2284 KB Output is correct
22 Correct 69 ms 2284 KB Output is correct
23 Correct 48 ms 2284 KB Output is correct
24 Correct 90 ms 2284 KB Output is correct
25 Correct 89 ms 2284 KB Output is correct
26 Correct 91 ms 2284 KB Output is correct
27 Correct 94 ms 2284 KB Output is correct
28 Correct 90 ms 2284 KB Output is correct
29 Correct 92 ms 2284 KB Output is correct
30 Correct 92 ms 2284 KB Output is correct
31 Correct 91 ms 2284 KB Output is correct
32 Correct 95 ms 2284 KB Output is correct
33 Correct 91 ms 2284 KB Output is correct
34 Correct 92 ms 2284 KB Output is correct
35 Correct 91 ms 2284 KB Output is correct
36 Correct 94 ms 2284 KB Output is correct
37 Correct 181 ms 2360 KB Output is correct
38 Correct 181 ms 2432 KB Output is correct
39 Correct 224 ms 2284 KB Output is correct
40 Correct 247 ms 2412 KB Output is correct
41 Correct 247 ms 2412 KB Output is correct
42 Correct 226 ms 2412 KB Output is correct
43 Correct 225 ms 2540 KB Output is correct
44 Correct 230 ms 2412 KB Output is correct
45 Correct 229 ms 2540 KB Output is correct
46 Correct 247 ms 2284 KB Output is correct
47 Correct 229 ms 2412 KB Output is correct
48 Correct 227 ms 2412 KB Output is correct
49 Correct 228 ms 2284 KB Output is correct
50 Correct 234 ms 2412 KB Output is correct
51 Correct 69 ms 1388 KB Output is correct
52 Correct 250 ms 2540 KB Output is correct
53 Correct 275 ms 2540 KB Output is correct
54 Correct 315 ms 2412 KB Output is correct
55 Correct 326 ms 2540 KB Output is correct
56 Correct 279 ms 2540 KB Output is correct
57 Correct 326 ms 2668 KB Output is correct
58 Correct 318 ms 2540 KB Output is correct
59 Correct 322 ms 2540 KB Output is correct
60 Correct 98 ms 1260 KB Output is correct
61 Correct 325 ms 2540 KB Output is correct
62 Correct 297 ms 2816 KB Output is correct
63 Correct 296 ms 2540 KB Output is correct
64 Correct 286 ms 2540 KB Output is correct
65 Correct 287 ms 2284 KB Output is correct
66 Correct 285 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2304 KB Output is correct
2 Correct 8 ms 2284 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 6 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 10 ms 2432 KB Output is correct
7 Correct 8 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 11 ms 2284 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 32 ms 2284 KB Output is correct
12 Correct 30 ms 2284 KB Output is correct
13 Correct 29 ms 2412 KB Output is correct
14 Correct 28 ms 2284 KB Output is correct
15 Correct 30 ms 2284 KB Output is correct
16 Correct 33 ms 2284 KB Output is correct
17 Correct 19 ms 2284 KB Output is correct
18 Correct 25 ms 2284 KB Output is correct
19 Correct 27 ms 2284 KB Output is correct
20 Correct 29 ms 2284 KB Output is correct
21 Correct 60 ms 2284 KB Output is correct
22 Correct 69 ms 2284 KB Output is correct
23 Correct 48 ms 2284 KB Output is correct
24 Correct 90 ms 2284 KB Output is correct
25 Correct 89 ms 2284 KB Output is correct
26 Correct 91 ms 2284 KB Output is correct
27 Correct 94 ms 2284 KB Output is correct
28 Correct 90 ms 2284 KB Output is correct
29 Correct 92 ms 2284 KB Output is correct
30 Correct 92 ms 2284 KB Output is correct
31 Correct 91 ms 2284 KB Output is correct
32 Correct 95 ms 2284 KB Output is correct
33 Correct 91 ms 2284 KB Output is correct
34 Correct 92 ms 2284 KB Output is correct
35 Correct 91 ms 2284 KB Output is correct
36 Correct 94 ms 2284 KB Output is correct
37 Correct 181 ms 2360 KB Output is correct
38 Correct 181 ms 2432 KB Output is correct
39 Correct 224 ms 2284 KB Output is correct
40 Correct 247 ms 2412 KB Output is correct
41 Correct 247 ms 2412 KB Output is correct
42 Correct 226 ms 2412 KB Output is correct
43 Correct 225 ms 2540 KB Output is correct
44 Correct 230 ms 2412 KB Output is correct
45 Correct 229 ms 2540 KB Output is correct
46 Correct 247 ms 2284 KB Output is correct
47 Correct 229 ms 2412 KB Output is correct
48 Correct 227 ms 2412 KB Output is correct
49 Correct 228 ms 2284 KB Output is correct
50 Correct 234 ms 2412 KB Output is correct
51 Correct 69 ms 1388 KB Output is correct
52 Correct 250 ms 2540 KB Output is correct
53 Correct 275 ms 2540 KB Output is correct
54 Correct 315 ms 2412 KB Output is correct
55 Correct 326 ms 2540 KB Output is correct
56 Correct 279 ms 2540 KB Output is correct
57 Correct 326 ms 2668 KB Output is correct
58 Correct 318 ms 2540 KB Output is correct
59 Correct 322 ms 2540 KB Output is correct
60 Correct 98 ms 1260 KB Output is correct
61 Correct 325 ms 2540 KB Output is correct
62 Correct 297 ms 2816 KB Output is correct
63 Correct 296 ms 2540 KB Output is correct
64 Correct 286 ms 2540 KB Output is correct
65 Correct 287 ms 2284 KB Output is correct
66 Correct 285 ms 2412 KB Output is correct
67 Correct 371 ms 2476 KB Output is correct
68 Correct 149 ms 1260 KB Output is correct
69 Correct 469 ms 3052 KB Output is correct
70 Correct 466 ms 2668 KB Output is correct
71 Correct 463 ms 2796 KB Output is correct
72 Correct 459 ms 2284 KB Output is correct
73 Correct 460 ms 2412 KB Output is correct
74 Correct 475 ms 3052 KB Output is correct
75 Correct 471 ms 3052 KB Output is correct
76 Correct 485 ms 2924 KB Output is correct
77 Correct 481 ms 3052 KB Output is correct