답안 #172911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172911 2020-01-02T18:04:26 Z LinusTorvaldsFan Bootfall (IZhO17_bootfall) C++14
65 / 100
849 ms 11364 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn=351;
const int maxc=351;
const int maxw=maxc*maxn;
bitset<maxn*maxc>available[maxn];



int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int>a(n);
	int sum=0;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0;i<=n;i++){
		available[i][0]=true;
		for(int j=0;j<n;j++){
			if(i==j)continue;
			available[i]|=available[i]<<a[j];
		}
	}
	if(sum&1){
		cout<<0;
		return 0;
	}
	if(!available[n][sum>>1]){
		cout<<0;
		return 0;
	}
	
	for(int i=0;i<n;i++){
		if((sum-a[i] & 1) != ((sum-a[0])&1)){
			cout<<0;
			return 0;
		}
	}
	
	vector<int>ans;
	for(int x=(sum-a[0])&1;x<=maxw;x+=2){
		bool ok=true;	
		for(int i=0;i<n;i++){
			int nsum=sum-a[i]+x;
			if(!available[i][nsum>>1]){
				ok=false;
				break;
			}
		}
		if(ok){
			ans.push_back(x);
		}
	}
	cout<<ans.size()<<endl;
	for(auto x:ans)cout<<x<<" ";
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:40:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   if((sum-a[i] & 1) != ((sum-a[0])&1)){
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 8 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 6 ms 760 KB Output is correct
14 Correct 7 ms 760 KB Output is correct
15 Correct 7 ms 760 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 4 ms 632 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 8 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 8 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 6 ms 760 KB Output is correct
14 Correct 7 ms 760 KB Output is correct
15 Correct 7 ms 760 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 4 ms 632 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 8 ms 888 KB Output is correct
21 Correct 28 ms 1528 KB Output is correct
22 Correct 36 ms 1528 KB Output is correct
23 Correct 18 ms 1144 KB Output is correct
24 Correct 56 ms 1912 KB Output is correct
25 Correct 138 ms 1832 KB Output is correct
26 Correct 63 ms 1916 KB Output is correct
27 Correct 63 ms 1912 KB Output is correct
28 Correct 63 ms 1912 KB Output is correct
29 Correct 63 ms 1912 KB Output is correct
30 Correct 62 ms 1824 KB Output is correct
31 Correct 64 ms 1912 KB Output is correct
32 Correct 63 ms 1896 KB Output is correct
33 Correct 62 ms 1912 KB Output is correct
34 Correct 62 ms 1912 KB Output is correct
35 Correct 63 ms 1912 KB Output is correct
36 Correct 64 ms 2040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 8 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 6 ms 760 KB Output is correct
14 Correct 7 ms 760 KB Output is correct
15 Correct 7 ms 760 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 4 ms 632 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 8 ms 888 KB Output is correct
21 Correct 28 ms 1528 KB Output is correct
22 Correct 36 ms 1528 KB Output is correct
23 Correct 18 ms 1144 KB Output is correct
24 Correct 56 ms 1912 KB Output is correct
25 Correct 138 ms 1832 KB Output is correct
26 Correct 63 ms 1916 KB Output is correct
27 Correct 63 ms 1912 KB Output is correct
28 Correct 63 ms 1912 KB Output is correct
29 Correct 63 ms 1912 KB Output is correct
30 Correct 62 ms 1824 KB Output is correct
31 Correct 64 ms 1912 KB Output is correct
32 Correct 63 ms 1896 KB Output is correct
33 Correct 62 ms 1912 KB Output is correct
34 Correct 62 ms 1912 KB Output is correct
35 Correct 63 ms 1912 KB Output is correct
36 Correct 64 ms 2040 KB Output is correct
37 Correct 245 ms 3548 KB Output is correct
38 Correct 244 ms 3576 KB Output is correct
39 Correct 366 ms 4268 KB Output is correct
40 Correct 443 ms 4812 KB Output is correct
41 Correct 434 ms 4484 KB Output is correct
42 Correct 379 ms 4472 KB Output is correct
43 Correct 371 ms 4540 KB Output is correct
44 Correct 382 ms 4480 KB Output is correct
45 Correct 389 ms 4748 KB Output is correct
46 Correct 426 ms 4600 KB Output is correct
47 Correct 382 ms 4548 KB Output is correct
48 Correct 383 ms 4472 KB Output is correct
49 Correct 373 ms 4304 KB Output is correct
50 Correct 384 ms 4408 KB Output is correct
51 Correct 372 ms 4264 KB Output is correct
52 Correct 451 ms 4896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 8 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 6 ms 760 KB Output is correct
14 Correct 7 ms 760 KB Output is correct
15 Correct 7 ms 760 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 4 ms 632 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 8 ms 888 KB Output is correct
21 Correct 28 ms 1528 KB Output is correct
22 Correct 36 ms 1528 KB Output is correct
23 Correct 18 ms 1144 KB Output is correct
24 Correct 56 ms 1912 KB Output is correct
25 Correct 138 ms 1832 KB Output is correct
26 Correct 63 ms 1916 KB Output is correct
27 Correct 63 ms 1912 KB Output is correct
28 Correct 63 ms 1912 KB Output is correct
29 Correct 63 ms 1912 KB Output is correct
30 Correct 62 ms 1824 KB Output is correct
31 Correct 64 ms 1912 KB Output is correct
32 Correct 63 ms 1896 KB Output is correct
33 Correct 62 ms 1912 KB Output is correct
34 Correct 62 ms 1912 KB Output is correct
35 Correct 63 ms 1912 KB Output is correct
36 Correct 64 ms 2040 KB Output is correct
37 Correct 245 ms 3548 KB Output is correct
38 Correct 244 ms 3576 KB Output is correct
39 Correct 366 ms 4268 KB Output is correct
40 Correct 443 ms 4812 KB Output is correct
41 Correct 434 ms 4484 KB Output is correct
42 Correct 379 ms 4472 KB Output is correct
43 Correct 371 ms 4540 KB Output is correct
44 Correct 382 ms 4480 KB Output is correct
45 Correct 389 ms 4748 KB Output is correct
46 Correct 426 ms 4600 KB Output is correct
47 Correct 382 ms 4548 KB Output is correct
48 Correct 383 ms 4472 KB Output is correct
49 Correct 373 ms 4304 KB Output is correct
50 Correct 384 ms 4408 KB Output is correct
51 Correct 372 ms 4264 KB Output is correct
52 Correct 451 ms 4896 KB Output is correct
53 Correct 551 ms 5244 KB Output is correct
54 Correct 747 ms 6228 KB Output is correct
55 Correct 765 ms 6360 KB Output is correct
56 Correct 575 ms 5492 KB Output is correct
57 Correct 767 ms 6428 KB Output is correct
58 Correct 752 ms 6156 KB Output is correct
59 Correct 755 ms 6148 KB Output is correct
60 Correct 723 ms 5772 KB Output is correct
61 Correct 762 ms 6424 KB Output is correct
62 Correct 642 ms 5920 KB Output is correct
63 Correct 648 ms 5892 KB Output is correct
64 Correct 626 ms 5880 KB Output is correct
65 Correct 592 ms 5208 KB Output is correct
66 Correct 575 ms 5368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 508 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 8 ms 888 KB Output is correct
12 Correct 8 ms 888 KB Output is correct
13 Correct 6 ms 760 KB Output is correct
14 Correct 7 ms 760 KB Output is correct
15 Correct 7 ms 760 KB Output is correct
16 Correct 8 ms 888 KB Output is correct
17 Correct 4 ms 632 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 8 ms 888 KB Output is correct
21 Correct 28 ms 1528 KB Output is correct
22 Correct 36 ms 1528 KB Output is correct
23 Correct 18 ms 1144 KB Output is correct
24 Correct 56 ms 1912 KB Output is correct
25 Correct 138 ms 1832 KB Output is correct
26 Correct 63 ms 1916 KB Output is correct
27 Correct 63 ms 1912 KB Output is correct
28 Correct 63 ms 1912 KB Output is correct
29 Correct 63 ms 1912 KB Output is correct
30 Correct 62 ms 1824 KB Output is correct
31 Correct 64 ms 1912 KB Output is correct
32 Correct 63 ms 1896 KB Output is correct
33 Correct 62 ms 1912 KB Output is correct
34 Correct 62 ms 1912 KB Output is correct
35 Correct 63 ms 1912 KB Output is correct
36 Correct 64 ms 2040 KB Output is correct
37 Correct 245 ms 3548 KB Output is correct
38 Correct 244 ms 3576 KB Output is correct
39 Correct 366 ms 4268 KB Output is correct
40 Correct 443 ms 4812 KB Output is correct
41 Correct 434 ms 4484 KB Output is correct
42 Correct 379 ms 4472 KB Output is correct
43 Correct 371 ms 4540 KB Output is correct
44 Correct 382 ms 4480 KB Output is correct
45 Correct 389 ms 4748 KB Output is correct
46 Correct 426 ms 4600 KB Output is correct
47 Correct 382 ms 4548 KB Output is correct
48 Correct 383 ms 4472 KB Output is correct
49 Correct 373 ms 4304 KB Output is correct
50 Correct 384 ms 4408 KB Output is correct
51 Correct 372 ms 4264 KB Output is correct
52 Correct 451 ms 4896 KB Output is correct
53 Correct 551 ms 5244 KB Output is correct
54 Correct 747 ms 6228 KB Output is correct
55 Correct 765 ms 6360 KB Output is correct
56 Correct 575 ms 5492 KB Output is correct
57 Correct 767 ms 6428 KB Output is correct
58 Correct 752 ms 6156 KB Output is correct
59 Correct 755 ms 6148 KB Output is correct
60 Correct 723 ms 5772 KB Output is correct
61 Correct 762 ms 6424 KB Output is correct
62 Correct 642 ms 5920 KB Output is correct
63 Correct 648 ms 5892 KB Output is correct
64 Correct 626 ms 5880 KB Output is correct
65 Correct 592 ms 5208 KB Output is correct
66 Correct 575 ms 5368 KB Output is correct
67 Runtime error 849 ms 11364 KB Execution killed with signal 11 (could be triggered by violating memory limits)
68 Halted 0 ms 0 KB -