Submission #172919

# Submission time Handle Problem Language Result Execution time Memory
172919 2020-01-02T18:15:06 Z LinusTorvaldsFan Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 7700 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn=400;
const int maxc=400;
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;
}
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 504 KB Output is correct
5 Correct 4 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 4 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 504 KB Output is correct
5 Correct 4 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 4 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 10 ms 1016 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 10 ms 1016 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 10 ms 1016 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 7 ms 888 KB Output is correct
19 Correct 8 ms 860 KB Output is correct
20 Correct 10 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 504 KB Output is correct
5 Correct 4 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 4 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 10 ms 1016 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 10 ms 1016 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 10 ms 1016 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 7 ms 888 KB Output is correct
19 Correct 8 ms 860 KB Output is correct
20 Correct 10 ms 1016 KB Output is correct
21 Correct 38 ms 1656 KB Output is correct
22 Correct 49 ms 1952 KB Output is correct
23 Correct 24 ms 1404 KB Output is correct
24 Correct 77 ms 2424 KB Output is correct
25 Correct 78 ms 2296 KB Output is correct
26 Correct 86 ms 2372 KB Output is correct
27 Correct 87 ms 2424 KB Output is correct
28 Correct 87 ms 2424 KB Output is correct
29 Correct 86 ms 2428 KB Output is correct
30 Correct 84 ms 2424 KB Output is correct
31 Correct 89 ms 2424 KB Output is correct
32 Correct 87 ms 2448 KB Output is correct
33 Correct 86 ms 2296 KB Output is correct
34 Correct 86 ms 2332 KB Output is correct
35 Correct 85 ms 2424 KB Output is correct
36 Correct 87 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 504 KB Output is correct
5 Correct 4 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 4 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 10 ms 1016 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 10 ms 1016 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 10 ms 1016 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 7 ms 888 KB Output is correct
19 Correct 8 ms 860 KB Output is correct
20 Correct 10 ms 1016 KB Output is correct
21 Correct 38 ms 1656 KB Output is correct
22 Correct 49 ms 1952 KB Output is correct
23 Correct 24 ms 1404 KB Output is correct
24 Correct 77 ms 2424 KB Output is correct
25 Correct 78 ms 2296 KB Output is correct
26 Correct 86 ms 2372 KB Output is correct
27 Correct 87 ms 2424 KB Output is correct
28 Correct 87 ms 2424 KB Output is correct
29 Correct 86 ms 2428 KB Output is correct
30 Correct 84 ms 2424 KB Output is correct
31 Correct 89 ms 2424 KB Output is correct
32 Correct 87 ms 2448 KB Output is correct
33 Correct 86 ms 2296 KB Output is correct
34 Correct 86 ms 2332 KB Output is correct
35 Correct 85 ms 2424 KB Output is correct
36 Correct 87 ms 2424 KB Output is correct
37 Correct 333 ms 4508 KB Output is correct
38 Correct 332 ms 4548 KB Output is correct
39 Correct 512 ms 5292 KB Output is correct
40 Correct 613 ms 6024 KB Output is correct
41 Correct 596 ms 5768 KB Output is correct
42 Correct 528 ms 5504 KB Output is correct
43 Correct 510 ms 5640 KB Output is correct
44 Correct 528 ms 5804 KB Output is correct
45 Correct 523 ms 5752 KB Output is correct
46 Correct 589 ms 5628 KB Output is correct
47 Correct 520 ms 5512 KB Output is correct
48 Correct 528 ms 5660 KB Output is correct
49 Correct 519 ms 5540 KB Output is correct
50 Correct 531 ms 5512 KB Output is correct
51 Correct 503 ms 5368 KB Output is correct
52 Correct 622 ms 6212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 504 KB Output is correct
5 Correct 4 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 4 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 10 ms 1016 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 10 ms 1016 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 10 ms 1016 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 7 ms 888 KB Output is correct
19 Correct 8 ms 860 KB Output is correct
20 Correct 10 ms 1016 KB Output is correct
21 Correct 38 ms 1656 KB Output is correct
22 Correct 49 ms 1952 KB Output is correct
23 Correct 24 ms 1404 KB Output is correct
24 Correct 77 ms 2424 KB Output is correct
25 Correct 78 ms 2296 KB Output is correct
26 Correct 86 ms 2372 KB Output is correct
27 Correct 87 ms 2424 KB Output is correct
28 Correct 87 ms 2424 KB Output is correct
29 Correct 86 ms 2428 KB Output is correct
30 Correct 84 ms 2424 KB Output is correct
31 Correct 89 ms 2424 KB Output is correct
32 Correct 87 ms 2448 KB Output is correct
33 Correct 86 ms 2296 KB Output is correct
34 Correct 86 ms 2332 KB Output is correct
35 Correct 85 ms 2424 KB Output is correct
36 Correct 87 ms 2424 KB Output is correct
37 Correct 333 ms 4508 KB Output is correct
38 Correct 332 ms 4548 KB Output is correct
39 Correct 512 ms 5292 KB Output is correct
40 Correct 613 ms 6024 KB Output is correct
41 Correct 596 ms 5768 KB Output is correct
42 Correct 528 ms 5504 KB Output is correct
43 Correct 510 ms 5640 KB Output is correct
44 Correct 528 ms 5804 KB Output is correct
45 Correct 523 ms 5752 KB Output is correct
46 Correct 589 ms 5628 KB Output is correct
47 Correct 520 ms 5512 KB Output is correct
48 Correct 528 ms 5660 KB Output is correct
49 Correct 519 ms 5540 KB Output is correct
50 Correct 531 ms 5512 KB Output is correct
51 Correct 503 ms 5368 KB Output is correct
52 Correct 622 ms 6212 KB Output is correct
53 Correct 759 ms 6700 KB Output is correct
54 Execution timed out 1012 ms 7700 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 504 KB Output is correct
5 Correct 4 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 4 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 10 ms 1016 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 10 ms 1016 KB Output is correct
13 Correct 8 ms 888 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 10 ms 1016 KB Output is correct
16 Correct 10 ms 1016 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 7 ms 888 KB Output is correct
19 Correct 8 ms 860 KB Output is correct
20 Correct 10 ms 1016 KB Output is correct
21 Correct 38 ms 1656 KB Output is correct
22 Correct 49 ms 1952 KB Output is correct
23 Correct 24 ms 1404 KB Output is correct
24 Correct 77 ms 2424 KB Output is correct
25 Correct 78 ms 2296 KB Output is correct
26 Correct 86 ms 2372 KB Output is correct
27 Correct 87 ms 2424 KB Output is correct
28 Correct 87 ms 2424 KB Output is correct
29 Correct 86 ms 2428 KB Output is correct
30 Correct 84 ms 2424 KB Output is correct
31 Correct 89 ms 2424 KB Output is correct
32 Correct 87 ms 2448 KB Output is correct
33 Correct 86 ms 2296 KB Output is correct
34 Correct 86 ms 2332 KB Output is correct
35 Correct 85 ms 2424 KB Output is correct
36 Correct 87 ms 2424 KB Output is correct
37 Correct 333 ms 4508 KB Output is correct
38 Correct 332 ms 4548 KB Output is correct
39 Correct 512 ms 5292 KB Output is correct
40 Correct 613 ms 6024 KB Output is correct
41 Correct 596 ms 5768 KB Output is correct
42 Correct 528 ms 5504 KB Output is correct
43 Correct 510 ms 5640 KB Output is correct
44 Correct 528 ms 5804 KB Output is correct
45 Correct 523 ms 5752 KB Output is correct
46 Correct 589 ms 5628 KB Output is correct
47 Correct 520 ms 5512 KB Output is correct
48 Correct 528 ms 5660 KB Output is correct
49 Correct 519 ms 5540 KB Output is correct
50 Correct 531 ms 5512 KB Output is correct
51 Correct 503 ms 5368 KB Output is correct
52 Correct 622 ms 6212 KB Output is correct
53 Correct 759 ms 6700 KB Output is correct
54 Execution timed out 1012 ms 7700 KB Time limit exceeded
55 Halted 0 ms 0 KB -