답안 #169778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169778 2019-12-22T20:41:03 Z super_j6 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 11128 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int maxn = 500, m = 250001;
int n;
int a[maxn], dp[m];
set<int> cur;
int s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		s += a[i];
		
		for(int j = s - a[i]; j >= 0; j--){
			dp[j + a[i]] += dp[j];
		}
	}
	
	if(s % 2 || !dp[s / 2]){
		cout << 0 << endl;
		cout << endl;
		return 0;
	}
	
	for(int i = 1; i < s; i++) cur.insert(i);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < s - a[i]; j++){
			dp[j + a[i]] -= dp[j];
		}
		
		for(auto it = cur.begin(); it != cur.end();){
			int x = *it;
			it++;
			if((s - a[i] + x) % 2 || !dp[(s - a[i] + x) / 2]) cur.erase(x);
		}
		
		for(int j = s - a[i]; j >= 0; j--){
			dp[j + a[i]] += dp[j];
		}
	}
	
	cout << cur.size() << endl;
	for(auto it = cur.begin(); it != cur.end();){
		int j = *it;
		it++;
		cout << j;
		if(it != cur.end()) cout << " ";
	}
	cout << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 6 ms 632 KB Output is correct
25 Correct 9 ms 888 KB Output is correct
26 Correct 10 ms 888 KB Output is correct
27 Correct 8 ms 760 KB Output is correct
28 Correct 8 ms 916 KB Output is correct
29 Correct 6 ms 888 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 10 ms 760 KB Output is correct
32 Correct 7 ms 632 KB Output is correct
33 Correct 5 ms 888 KB Output is correct
34 Correct 6 ms 888 KB Output is correct
35 Correct 6 ms 760 KB Output is correct
36 Correct 6 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 6 ms 632 KB Output is correct
25 Correct 9 ms 888 KB Output is correct
26 Correct 10 ms 888 KB Output is correct
27 Correct 8 ms 760 KB Output is correct
28 Correct 8 ms 916 KB Output is correct
29 Correct 6 ms 888 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 10 ms 760 KB Output is correct
32 Correct 7 ms 632 KB Output is correct
33 Correct 5 ms 888 KB Output is correct
34 Correct 6 ms 888 KB Output is correct
35 Correct 6 ms 760 KB Output is correct
36 Correct 6 ms 632 KB Output is correct
37 Correct 42 ms 1400 KB Output is correct
38 Correct 41 ms 1400 KB Output is correct
39 Correct 45 ms 3448 KB Output is correct
40 Correct 88 ms 2068 KB Output is correct
41 Correct 56 ms 4088 KB Output is correct
42 Correct 76 ms 1912 KB Output is correct
43 Correct 130 ms 3352 KB Output is correct
44 Correct 141 ms 3320 KB Output is correct
45 Correct 139 ms 3388 KB Output is correct
46 Correct 24 ms 1916 KB Output is correct
47 Correct 86 ms 2040 KB Output is correct
48 Correct 112 ms 3576 KB Output is correct
49 Correct 64 ms 3576 KB Output is correct
50 Correct 83 ms 2040 KB Output is correct
51 Correct 4 ms 504 KB Output is correct
52 Correct 173 ms 4112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 6 ms 632 KB Output is correct
25 Correct 9 ms 888 KB Output is correct
26 Correct 10 ms 888 KB Output is correct
27 Correct 8 ms 760 KB Output is correct
28 Correct 8 ms 916 KB Output is correct
29 Correct 6 ms 888 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 10 ms 760 KB Output is correct
32 Correct 7 ms 632 KB Output is correct
33 Correct 5 ms 888 KB Output is correct
34 Correct 6 ms 888 KB Output is correct
35 Correct 6 ms 760 KB Output is correct
36 Correct 6 ms 632 KB Output is correct
37 Correct 42 ms 1400 KB Output is correct
38 Correct 41 ms 1400 KB Output is correct
39 Correct 45 ms 3448 KB Output is correct
40 Correct 88 ms 2068 KB Output is correct
41 Correct 56 ms 4088 KB Output is correct
42 Correct 76 ms 1912 KB Output is correct
43 Correct 130 ms 3352 KB Output is correct
44 Correct 141 ms 3320 KB Output is correct
45 Correct 139 ms 3388 KB Output is correct
46 Correct 24 ms 1916 KB Output is correct
47 Correct 86 ms 2040 KB Output is correct
48 Correct 112 ms 3576 KB Output is correct
49 Correct 64 ms 3576 KB Output is correct
50 Correct 83 ms 2040 KB Output is correct
51 Correct 4 ms 504 KB Output is correct
52 Correct 173 ms 4112 KB Output is correct
53 Correct 135 ms 2852 KB Output is correct
54 Correct 216 ms 3380 KB Output is correct
55 Correct 359 ms 6392 KB Output is correct
56 Correct 169 ms 3448 KB Output is correct
57 Correct 372 ms 6648 KB Output is correct
58 Correct 218 ms 3660 KB Output is correct
59 Correct 271 ms 4472 KB Output is correct
60 Correct 8 ms 504 KB Output is correct
61 Correct 296 ms 4984 KB Output is correct
62 Correct 294 ms 5624 KB Output is correct
63 Correct 322 ms 6008 KB Output is correct
64 Correct 310 ms 5840 KB Output is correct
65 Correct 49 ms 2936 KB Output is correct
66 Correct 83 ms 3064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 504 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 6 ms 632 KB Output is correct
25 Correct 9 ms 888 KB Output is correct
26 Correct 10 ms 888 KB Output is correct
27 Correct 8 ms 760 KB Output is correct
28 Correct 8 ms 916 KB Output is correct
29 Correct 6 ms 888 KB Output is correct
30 Correct 4 ms 632 KB Output is correct
31 Correct 10 ms 760 KB Output is correct
32 Correct 7 ms 632 KB Output is correct
33 Correct 5 ms 888 KB Output is correct
34 Correct 6 ms 888 KB Output is correct
35 Correct 6 ms 760 KB Output is correct
36 Correct 6 ms 632 KB Output is correct
37 Correct 42 ms 1400 KB Output is correct
38 Correct 41 ms 1400 KB Output is correct
39 Correct 45 ms 3448 KB Output is correct
40 Correct 88 ms 2068 KB Output is correct
41 Correct 56 ms 4088 KB Output is correct
42 Correct 76 ms 1912 KB Output is correct
43 Correct 130 ms 3352 KB Output is correct
44 Correct 141 ms 3320 KB Output is correct
45 Correct 139 ms 3388 KB Output is correct
46 Correct 24 ms 1916 KB Output is correct
47 Correct 86 ms 2040 KB Output is correct
48 Correct 112 ms 3576 KB Output is correct
49 Correct 64 ms 3576 KB Output is correct
50 Correct 83 ms 2040 KB Output is correct
51 Correct 4 ms 504 KB Output is correct
52 Correct 173 ms 4112 KB Output is correct
53 Correct 135 ms 2852 KB Output is correct
54 Correct 216 ms 3380 KB Output is correct
55 Correct 359 ms 6392 KB Output is correct
56 Correct 169 ms 3448 KB Output is correct
57 Correct 372 ms 6648 KB Output is correct
58 Correct 218 ms 3660 KB Output is correct
59 Correct 271 ms 4472 KB Output is correct
60 Correct 8 ms 504 KB Output is correct
61 Correct 296 ms 4984 KB Output is correct
62 Correct 294 ms 5624 KB Output is correct
63 Correct 322 ms 6008 KB Output is correct
64 Correct 310 ms 5840 KB Output is correct
65 Correct 49 ms 2936 KB Output is correct
66 Correct 83 ms 3064 KB Output is correct
67 Correct 311 ms 4584 KB Output is correct
68 Correct 21 ms 764 KB Output is correct
69 Execution timed out 1066 ms 11128 KB Time limit exceeded
70 Halted 0 ms 0 KB -