Submission #63260

# Submission time Handle Problem Language Result Execution time Memory
63260 2018-08-01T07:32:53 Z Tenuun Bootfall (IZhO17_bootfall) C++17
13 / 100
5 ms 2660 KB
#include<bits/stdc++.h>

using namespace std;

int sum=0;
int c[250001], res[250001];

void add(int t){
	sum+=t;
	for(int i=sum; i>=t; i--){
		c[i]+=c[i-t];
	}
}

void del(int t){
	sum-=t;
	for(int i=t; i<=sum; i++){
		c[i]-=c[i-t];
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(c, 0, sizeof c);
	memset(res, 0, sizeof res);
	c[0]=1;
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) {
		cin >> a[i];
		add(a[i]);
	}
	if(sum%2 || !c[sum/2]) return cout << 0, 0;
	for(int i=0; i<n; i++){
		del(a[i]);
		for(int j=1; j<=sum; j++){
			if((sum+j)%2) continue;
			if(c[(sum+j)/2]) res[j]++;
		}
		add(a[i]);
	}
	vector<int> ans;
	for(int i=1; i<=sum; i++){
		if(res[i]==n) ans.push_back(i);
	}
	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++) cout << ans[i] << " ";
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ans.size(); i++) cout << ans[i] << " ";
               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 5 ms 2300 KB Output is correct
3 Correct 4 ms 2348 KB Output is correct
4 Correct 5 ms 2388 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 5 ms 2472 KB Output is correct
7 Correct 4 ms 2472 KB Output is correct
8 Correct 4 ms 2472 KB Output is correct
9 Correct 4 ms 2472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 5 ms 2300 KB Output is correct
3 Correct 4 ms 2348 KB Output is correct
4 Correct 5 ms 2388 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 5 ms 2472 KB Output is correct
7 Correct 4 ms 2472 KB Output is correct
8 Correct 4 ms 2472 KB Output is correct
9 Correct 4 ms 2472 KB Output is correct
10 Correct 4 ms 2480 KB Output is correct
11 Correct 4 ms 2528 KB Output is correct
12 Correct 4 ms 2616 KB Output is correct
13 Correct 5 ms 2660 KB Output is correct
14 Correct 4 ms 2660 KB Output is correct
15 Correct 5 ms 2660 KB Output is correct
16 Correct 5 ms 2660 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2660 KB Output is correct
19 Correct 5 ms 2660 KB Output is correct
20 Correct 5 ms 2660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 5 ms 2300 KB Output is correct
3 Correct 4 ms 2348 KB Output is correct
4 Correct 5 ms 2388 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 5 ms 2472 KB Output is correct
7 Correct 4 ms 2472 KB Output is correct
8 Correct 4 ms 2472 KB Output is correct
9 Correct 4 ms 2472 KB Output is correct
10 Correct 4 ms 2480 KB Output is correct
11 Correct 4 ms 2528 KB Output is correct
12 Correct 4 ms 2616 KB Output is correct
13 Correct 5 ms 2660 KB Output is correct
14 Correct 4 ms 2660 KB Output is correct
15 Correct 5 ms 2660 KB Output is correct
16 Correct 5 ms 2660 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2660 KB Output is correct
19 Correct 5 ms 2660 KB Output is correct
20 Correct 5 ms 2660 KB Output is correct
21 Correct 5 ms 2660 KB Output is correct
22 Correct 4 ms 2660 KB Output is correct
23 Incorrect 5 ms 2660 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 5 ms 2300 KB Output is correct
3 Correct 4 ms 2348 KB Output is correct
4 Correct 5 ms 2388 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 5 ms 2472 KB Output is correct
7 Correct 4 ms 2472 KB Output is correct
8 Correct 4 ms 2472 KB Output is correct
9 Correct 4 ms 2472 KB Output is correct
10 Correct 4 ms 2480 KB Output is correct
11 Correct 4 ms 2528 KB Output is correct
12 Correct 4 ms 2616 KB Output is correct
13 Correct 5 ms 2660 KB Output is correct
14 Correct 4 ms 2660 KB Output is correct
15 Correct 5 ms 2660 KB Output is correct
16 Correct 5 ms 2660 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2660 KB Output is correct
19 Correct 5 ms 2660 KB Output is correct
20 Correct 5 ms 2660 KB Output is correct
21 Correct 5 ms 2660 KB Output is correct
22 Correct 4 ms 2660 KB Output is correct
23 Incorrect 5 ms 2660 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 5 ms 2300 KB Output is correct
3 Correct 4 ms 2348 KB Output is correct
4 Correct 5 ms 2388 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 5 ms 2472 KB Output is correct
7 Correct 4 ms 2472 KB Output is correct
8 Correct 4 ms 2472 KB Output is correct
9 Correct 4 ms 2472 KB Output is correct
10 Correct 4 ms 2480 KB Output is correct
11 Correct 4 ms 2528 KB Output is correct
12 Correct 4 ms 2616 KB Output is correct
13 Correct 5 ms 2660 KB Output is correct
14 Correct 4 ms 2660 KB Output is correct
15 Correct 5 ms 2660 KB Output is correct
16 Correct 5 ms 2660 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2660 KB Output is correct
19 Correct 5 ms 2660 KB Output is correct
20 Correct 5 ms 2660 KB Output is correct
21 Correct 5 ms 2660 KB Output is correct
22 Correct 4 ms 2660 KB Output is correct
23 Incorrect 5 ms 2660 KB Output isn't correct
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2296 KB Output is correct
2 Correct 5 ms 2300 KB Output is correct
3 Correct 4 ms 2348 KB Output is correct
4 Correct 5 ms 2388 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 5 ms 2472 KB Output is correct
7 Correct 4 ms 2472 KB Output is correct
8 Correct 4 ms 2472 KB Output is correct
9 Correct 4 ms 2472 KB Output is correct
10 Correct 4 ms 2480 KB Output is correct
11 Correct 4 ms 2528 KB Output is correct
12 Correct 4 ms 2616 KB Output is correct
13 Correct 5 ms 2660 KB Output is correct
14 Correct 4 ms 2660 KB Output is correct
15 Correct 5 ms 2660 KB Output is correct
16 Correct 5 ms 2660 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2660 KB Output is correct
19 Correct 5 ms 2660 KB Output is correct
20 Correct 5 ms 2660 KB Output is correct
21 Correct 5 ms 2660 KB Output is correct
22 Correct 4 ms 2660 KB Output is correct
23 Incorrect 5 ms 2660 KB Output isn't correct
24 Halted 0 ms 0 KB -