답안 #340221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340221 2020-12-27T10:23:21 Z Tosic Bootfall (IZhO17_bootfall) C++14
100 / 100
319 ms 2924 KB
#include <bits/stdc++.h>
#define maxn 510
using namespace std;

int n, a[maxn], kS[maxn*maxn], isOk[maxn*maxn], ans, sum;


int main(){
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		sum += a[i];
	}
		kS[0] = 1;
	for(int i = 0; i < n; ++i){
		for(int j = sum-a[i]; j >= 0; --j){
			kS[j+a[i]] += kS[j];
		}
	}if(sum%2 or !kS[sum/2]){
		cout <<0;
		return 0;
	}

	for(int i = 0; i < n; ++i){
		int tmp = sum-a[i];
		for(int j = a[i]; j <= sum; ++j){
			kS[j] -= kS[j-a[i]];
            //cerr << kS[j] << ' ';
			if(2*j - tmp > 0 and kS[j]){
				isOk[2*j - tmp]++;
				if(isOk[-tmp+j*2] == n){
					++ans;
				}
			}
		}
		for(int j = 1; j < a[i]; ++j){
			if(2*j - tmp > 0 and kS[j]){
				isOk[2*j - tmp]++;
				if(isOk[-tmp+j*2] == n){
					++ans;
				}
			}
		}
		cerr << '\n';
		for(int j = sum-a[i]; j >= 0; --j){
			kS[j+a[i]] += kS[j];
		}
	}
	cout << ans << '\n';
	for(int i = 1; i <= sum; ++i){
		if(isOk[i] == n){
			cout << i << ' ';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 4 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 4 ms 492 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 5 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 4 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 4 ms 492 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 5 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 15 ms 620 KB Output is correct
38 Correct 12 ms 620 KB Output is correct
39 Correct 36 ms 876 KB Output is correct
40 Correct 25 ms 748 KB Output is correct
41 Correct 57 ms 876 KB Output is correct
42 Correct 21 ms 748 KB Output is correct
43 Correct 40 ms 1004 KB Output is correct
44 Correct 39 ms 1004 KB Output is correct
45 Correct 39 ms 1004 KB Output is correct
46 Correct 22 ms 620 KB Output is correct
47 Correct 27 ms 748 KB Output is correct
48 Correct 41 ms 1024 KB Output is correct
49 Correct 45 ms 876 KB Output is correct
50 Correct 23 ms 748 KB Output is correct
51 Correct 5 ms 492 KB Output is correct
52 Correct 53 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 4 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 4 ms 492 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 5 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 15 ms 620 KB Output is correct
38 Correct 12 ms 620 KB Output is correct
39 Correct 36 ms 876 KB Output is correct
40 Correct 25 ms 748 KB Output is correct
41 Correct 57 ms 876 KB Output is correct
42 Correct 21 ms 748 KB Output is correct
43 Correct 40 ms 1004 KB Output is correct
44 Correct 39 ms 1004 KB Output is correct
45 Correct 39 ms 1004 KB Output is correct
46 Correct 22 ms 620 KB Output is correct
47 Correct 27 ms 748 KB Output is correct
48 Correct 41 ms 1024 KB Output is correct
49 Correct 45 ms 876 KB Output is correct
50 Correct 23 ms 748 KB Output is correct
51 Correct 5 ms 492 KB Output is correct
52 Correct 53 ms 1132 KB Output is correct
53 Correct 38 ms 876 KB Output is correct
54 Correct 56 ms 972 KB Output is correct
55 Correct 110 ms 1516 KB Output is correct
56 Correct 48 ms 1132 KB Output is correct
57 Correct 110 ms 1644 KB Output is correct
58 Correct 58 ms 1004 KB Output is correct
59 Correct 73 ms 1132 KB Output is correct
60 Correct 12 ms 620 KB Output is correct
61 Correct 81 ms 1260 KB Output is correct
62 Correct 84 ms 1388 KB Output is correct
63 Correct 94 ms 1644 KB Output is correct
64 Correct 89 ms 1388 KB Output is correct
65 Correct 39 ms 876 KB Output is correct
66 Correct 40 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 4 ms 492 KB Output is correct
27 Correct 4 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 4 ms 492 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 5 ms 492 KB Output is correct
34 Correct 3 ms 492 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 15 ms 620 KB Output is correct
38 Correct 12 ms 620 KB Output is correct
39 Correct 36 ms 876 KB Output is correct
40 Correct 25 ms 748 KB Output is correct
41 Correct 57 ms 876 KB Output is correct
42 Correct 21 ms 748 KB Output is correct
43 Correct 40 ms 1004 KB Output is correct
44 Correct 39 ms 1004 KB Output is correct
45 Correct 39 ms 1004 KB Output is correct
46 Correct 22 ms 620 KB Output is correct
47 Correct 27 ms 748 KB Output is correct
48 Correct 41 ms 1024 KB Output is correct
49 Correct 45 ms 876 KB Output is correct
50 Correct 23 ms 748 KB Output is correct
51 Correct 5 ms 492 KB Output is correct
52 Correct 53 ms 1132 KB Output is correct
53 Correct 38 ms 876 KB Output is correct
54 Correct 56 ms 972 KB Output is correct
55 Correct 110 ms 1516 KB Output is correct
56 Correct 48 ms 1132 KB Output is correct
57 Correct 110 ms 1644 KB Output is correct
58 Correct 58 ms 1004 KB Output is correct
59 Correct 73 ms 1132 KB Output is correct
60 Correct 12 ms 620 KB Output is correct
61 Correct 81 ms 1260 KB Output is correct
62 Correct 84 ms 1388 KB Output is correct
63 Correct 94 ms 1644 KB Output is correct
64 Correct 89 ms 1388 KB Output is correct
65 Correct 39 ms 876 KB Output is correct
66 Correct 40 ms 748 KB Output is correct
67 Correct 87 ms 1260 KB Output is correct
68 Correct 33 ms 876 KB Output is correct
69 Correct 278 ms 2796 KB Output is correct
70 Correct 170 ms 1900 KB Output is correct
71 Correct 165 ms 1772 KB Output is correct
72 Correct 160 ms 1388 KB Output is correct
73 Correct 160 ms 1388 KB Output is correct
74 Correct 295 ms 2800 KB Output is correct
75 Correct 228 ms 2284 KB Output is correct
76 Correct 319 ms 2924 KB Output is correct
77 Correct 316 ms 2924 KB Output is correct