Submission #62788

# Submission time Handle Problem Language Result Execution time Memory
62788 2018-07-30T04:12:53 Z Tenuun Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 2324 KB
#include<bits/stdc++.h>
 
using namespace std;
 
int n, a[500], res[250001];

bool s[250001];

void check(){
	s[0]=true;
	vector<int> tmp;
	tmp.push_back(0);
	int sz;
	for(int i=0; i<n; i++){
		sz=tmp.size();
		for(int j=0; j<sz; j++){
			if(!s[tmp[j]+a[i]]){
				s[tmp[j]+a[i]]=true;
				tmp.push_back(tmp[j]+a[i]);
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tot=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		tot+=a[i];
	}
	memset(res, 0, sizeof res);
	memset(s, 0, sizeof s);
	check();
	if(tot%2 || !s[tot/2]){
		return cout << 0, 0;
	}
	int tmp;
	for(int i=0; i<n; i++){
		tmp=a[i];
		a[i]=0;
		memset(s, 0, sizeof s);
		check();
		tot-=tmp;
		for(int j=1; j<=tot; j++){
			if((tot+j)%2) continue;
			if(s[(tot+j)/2]){
				res[j]++;
			}
		}
		bool ok=false;
		for(int j=1; j<=tot; j++){
			if(res[j]==i+1) ok=true;
		}
		if(!ok) break;
		tot+=tmp;
		a[i]=tmp;
	}
	vector<int>res;
	for(int i=1; i<=tot; i++){
		if(::res[i]==n){
			res.push_back(i);
		}
	}
	cout << res.size() << endl;
	for(int i=0; i<res.size(); i++) cout << res[i] << " ";
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:68:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<res.size(); i++) cout << res[i] << " ";
               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1768 KB Output is correct
4 Correct 3 ms 1768 KB Output is correct
5 Correct 3 ms 1768 KB Output is correct
6 Correct 4 ms 1768 KB Output is correct
7 Correct 4 ms 1768 KB Output is correct
8 Correct 5 ms 1768 KB Output is correct
9 Correct 4 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1768 KB Output is correct
4 Correct 3 ms 1768 KB Output is correct
5 Correct 3 ms 1768 KB Output is correct
6 Correct 4 ms 1768 KB Output is correct
7 Correct 4 ms 1768 KB Output is correct
8 Correct 5 ms 1768 KB Output is correct
9 Correct 4 ms 1884 KB Output is correct
10 Correct 4 ms 1884 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 4 ms 1884 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 4 ms 1884 KB Output is correct
15 Correct 4 ms 1884 KB Output is correct
16 Correct 5 ms 1884 KB Output is correct
17 Correct 4 ms 1900 KB Output is correct
18 Correct 6 ms 1900 KB Output is correct
19 Correct 4 ms 1900 KB Output is correct
20 Correct 5 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1768 KB Output is correct
4 Correct 3 ms 1768 KB Output is correct
5 Correct 3 ms 1768 KB Output is correct
6 Correct 4 ms 1768 KB Output is correct
7 Correct 4 ms 1768 KB Output is correct
8 Correct 5 ms 1768 KB Output is correct
9 Correct 4 ms 1884 KB Output is correct
10 Correct 4 ms 1884 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 4 ms 1884 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 4 ms 1884 KB Output is correct
15 Correct 4 ms 1884 KB Output is correct
16 Correct 5 ms 1884 KB Output is correct
17 Correct 4 ms 1900 KB Output is correct
18 Correct 6 ms 1900 KB Output is correct
19 Correct 4 ms 1900 KB Output is correct
20 Correct 5 ms 1900 KB Output is correct
21 Correct 15 ms 1900 KB Output is correct
22 Correct 23 ms 1916 KB Output is correct
23 Correct 12 ms 1932 KB Output is correct
24 Correct 32 ms 2068 KB Output is correct
25 Correct 41 ms 2084 KB Output is correct
26 Correct 48 ms 2084 KB Output is correct
27 Correct 33 ms 2084 KB Output is correct
28 Correct 28 ms 2084 KB Output is correct
29 Correct 30 ms 2084 KB Output is correct
30 Correct 6 ms 2084 KB Output is correct
31 Correct 56 ms 2084 KB Output is correct
32 Correct 43 ms 2084 KB Output is correct
33 Correct 9 ms 2084 KB Output is correct
34 Correct 8 ms 2084 KB Output is correct
35 Correct 29 ms 2084 KB Output is correct
36 Correct 39 ms 2084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1768 KB Output is correct
4 Correct 3 ms 1768 KB Output is correct
5 Correct 3 ms 1768 KB Output is correct
6 Correct 4 ms 1768 KB Output is correct
7 Correct 4 ms 1768 KB Output is correct
8 Correct 5 ms 1768 KB Output is correct
9 Correct 4 ms 1884 KB Output is correct
10 Correct 4 ms 1884 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 4 ms 1884 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 4 ms 1884 KB Output is correct
15 Correct 4 ms 1884 KB Output is correct
16 Correct 5 ms 1884 KB Output is correct
17 Correct 4 ms 1900 KB Output is correct
18 Correct 6 ms 1900 KB Output is correct
19 Correct 4 ms 1900 KB Output is correct
20 Correct 5 ms 1900 KB Output is correct
21 Correct 15 ms 1900 KB Output is correct
22 Correct 23 ms 1916 KB Output is correct
23 Correct 12 ms 1932 KB Output is correct
24 Correct 32 ms 2068 KB Output is correct
25 Correct 41 ms 2084 KB Output is correct
26 Correct 48 ms 2084 KB Output is correct
27 Correct 33 ms 2084 KB Output is correct
28 Correct 28 ms 2084 KB Output is correct
29 Correct 30 ms 2084 KB Output is correct
30 Correct 6 ms 2084 KB Output is correct
31 Correct 56 ms 2084 KB Output is correct
32 Correct 43 ms 2084 KB Output is correct
33 Correct 9 ms 2084 KB Output is correct
34 Correct 8 ms 2084 KB Output is correct
35 Correct 29 ms 2084 KB Output is correct
36 Correct 39 ms 2084 KB Output is correct
37 Correct 526 ms 2248 KB Output is correct
38 Correct 495 ms 2324 KB Output is correct
39 Correct 51 ms 2324 KB Output is correct
40 Execution timed out 1074 ms 2324 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1768 KB Output is correct
4 Correct 3 ms 1768 KB Output is correct
5 Correct 3 ms 1768 KB Output is correct
6 Correct 4 ms 1768 KB Output is correct
7 Correct 4 ms 1768 KB Output is correct
8 Correct 5 ms 1768 KB Output is correct
9 Correct 4 ms 1884 KB Output is correct
10 Correct 4 ms 1884 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 4 ms 1884 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 4 ms 1884 KB Output is correct
15 Correct 4 ms 1884 KB Output is correct
16 Correct 5 ms 1884 KB Output is correct
17 Correct 4 ms 1900 KB Output is correct
18 Correct 6 ms 1900 KB Output is correct
19 Correct 4 ms 1900 KB Output is correct
20 Correct 5 ms 1900 KB Output is correct
21 Correct 15 ms 1900 KB Output is correct
22 Correct 23 ms 1916 KB Output is correct
23 Correct 12 ms 1932 KB Output is correct
24 Correct 32 ms 2068 KB Output is correct
25 Correct 41 ms 2084 KB Output is correct
26 Correct 48 ms 2084 KB Output is correct
27 Correct 33 ms 2084 KB Output is correct
28 Correct 28 ms 2084 KB Output is correct
29 Correct 30 ms 2084 KB Output is correct
30 Correct 6 ms 2084 KB Output is correct
31 Correct 56 ms 2084 KB Output is correct
32 Correct 43 ms 2084 KB Output is correct
33 Correct 9 ms 2084 KB Output is correct
34 Correct 8 ms 2084 KB Output is correct
35 Correct 29 ms 2084 KB Output is correct
36 Correct 39 ms 2084 KB Output is correct
37 Correct 526 ms 2248 KB Output is correct
38 Correct 495 ms 2324 KB Output is correct
39 Correct 51 ms 2324 KB Output is correct
40 Execution timed out 1074 ms 2324 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 5 ms 1768 KB Output is correct
3 Correct 5 ms 1768 KB Output is correct
4 Correct 3 ms 1768 KB Output is correct
5 Correct 3 ms 1768 KB Output is correct
6 Correct 4 ms 1768 KB Output is correct
7 Correct 4 ms 1768 KB Output is correct
8 Correct 5 ms 1768 KB Output is correct
9 Correct 4 ms 1884 KB Output is correct
10 Correct 4 ms 1884 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 4 ms 1884 KB Output is correct
13 Correct 5 ms 1884 KB Output is correct
14 Correct 4 ms 1884 KB Output is correct
15 Correct 4 ms 1884 KB Output is correct
16 Correct 5 ms 1884 KB Output is correct
17 Correct 4 ms 1900 KB Output is correct
18 Correct 6 ms 1900 KB Output is correct
19 Correct 4 ms 1900 KB Output is correct
20 Correct 5 ms 1900 KB Output is correct
21 Correct 15 ms 1900 KB Output is correct
22 Correct 23 ms 1916 KB Output is correct
23 Correct 12 ms 1932 KB Output is correct
24 Correct 32 ms 2068 KB Output is correct
25 Correct 41 ms 2084 KB Output is correct
26 Correct 48 ms 2084 KB Output is correct
27 Correct 33 ms 2084 KB Output is correct
28 Correct 28 ms 2084 KB Output is correct
29 Correct 30 ms 2084 KB Output is correct
30 Correct 6 ms 2084 KB Output is correct
31 Correct 56 ms 2084 KB Output is correct
32 Correct 43 ms 2084 KB Output is correct
33 Correct 9 ms 2084 KB Output is correct
34 Correct 8 ms 2084 KB Output is correct
35 Correct 29 ms 2084 KB Output is correct
36 Correct 39 ms 2084 KB Output is correct
37 Correct 526 ms 2248 KB Output is correct
38 Correct 495 ms 2324 KB Output is correct
39 Correct 51 ms 2324 KB Output is correct
40 Execution timed out 1074 ms 2324 KB Time limit exceeded
41 Halted 0 ms 0 KB -