Submission #877002

# Submission time Handle Problem Language Result Execution time Memory
877002 2023-11-22T16:39:23 Z pera Bootfall (IZhO17_bootfall) C++17
13 / 100
1000 ms 74332 KB
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 2e5 + 1;
int dp[500][501 * 501];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n , s = 0;cin >> n;
	vector<int> a(n + 1) , ans;
	for(int i = 1;i <= n;i ++){
		for(int x = 0;x <= 500 * 500;x ++){
			dp[i][x] = 0;
		}
	}
	for(int i = 0;i <= n;i ++) dp[i][0] = 1;
	for(int i = 1;i <= n;i ++){
		cin >> a[i];
		s += a[i];
		for(int x = 500 * 500;x >= a[i];x --) dp[0][x] |= dp[0][x - a[i]];
		for(int p = 1;p <= n;p ++){
			if(p != i){
				for(int x = 500 * 500;x >= a[i];x --) dp[p][x] |= dp[p][x - a[i]];
			}
		}
	}
	for(int x = 1;x <= 500 * 500;x ++){
		int ok = 1;
		ok &= (s % 2 == 0 && dp[0][s / 2]);
		for(int i = 1;i <= n;i ++){
			ok &= ((s + x - a[i]) / 2 <= 500 * 500 && (s + x - a[i]) % 2 == 0 && dp[i][(s + x - a[i]) / 2]);
		}		
		if(ok) ans.push_back(x);
	}
	cout << ans.size() << endl;
	for(int i = 0;i < ans.size();i ++){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i = 0;i < ans.size();i ++){
      |                ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6604 KB Output is correct
2 Correct 11 ms 8848 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 5 ms 6748 KB Output is correct
5 Correct 39 ms 14980 KB Output is correct
6 Correct 22 ms 11052 KB Output is correct
7 Correct 14 ms 8796 KB Output is correct
8 Correct 32 ms 14976 KB Output is correct
9 Correct 25 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6604 KB Output is correct
2 Correct 11 ms 8848 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 5 ms 6748 KB Output is correct
5 Correct 39 ms 14980 KB Output is correct
6 Correct 22 ms 11052 KB Output is correct
7 Correct 14 ms 8796 KB Output is correct
8 Correct 32 ms 14976 KB Output is correct
9 Correct 25 ms 12892 KB Output is correct
10 Correct 199 ms 31396 KB Output is correct
11 Correct 185 ms 31396 KB Output is correct
12 Correct 184 ms 31392 KB Output is correct
13 Correct 147 ms 27292 KB Output is correct
14 Correct 167 ms 29344 KB Output is correct
15 Correct 202 ms 29340 KB Output is correct
16 Correct 178 ms 31324 KB Output is correct
17 Correct 73 ms 21084 KB Output is correct
18 Correct 156 ms 25236 KB Output is correct
19 Correct 133 ms 27292 KB Output is correct
20 Correct 196 ms 31324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6604 KB Output is correct
2 Correct 11 ms 8848 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 5 ms 6748 KB Output is correct
5 Correct 39 ms 14980 KB Output is correct
6 Correct 22 ms 11052 KB Output is correct
7 Correct 14 ms 8796 KB Output is correct
8 Correct 32 ms 14976 KB Output is correct
9 Correct 25 ms 12892 KB Output is correct
10 Correct 199 ms 31396 KB Output is correct
11 Correct 185 ms 31396 KB Output is correct
12 Correct 184 ms 31392 KB Output is correct
13 Correct 147 ms 27292 KB Output is correct
14 Correct 167 ms 29344 KB Output is correct
15 Correct 202 ms 29340 KB Output is correct
16 Correct 178 ms 31324 KB Output is correct
17 Correct 73 ms 21084 KB Output is correct
18 Correct 156 ms 25236 KB Output is correct
19 Correct 133 ms 27292 KB Output is correct
20 Correct 196 ms 31324 KB Output is correct
21 Correct 815 ms 66276 KB Output is correct
22 Execution timed out 1081 ms 74332 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6604 KB Output is correct
2 Correct 11 ms 8848 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 5 ms 6748 KB Output is correct
5 Correct 39 ms 14980 KB Output is correct
6 Correct 22 ms 11052 KB Output is correct
7 Correct 14 ms 8796 KB Output is correct
8 Correct 32 ms 14976 KB Output is correct
9 Correct 25 ms 12892 KB Output is correct
10 Correct 199 ms 31396 KB Output is correct
11 Correct 185 ms 31396 KB Output is correct
12 Correct 184 ms 31392 KB Output is correct
13 Correct 147 ms 27292 KB Output is correct
14 Correct 167 ms 29344 KB Output is correct
15 Correct 202 ms 29340 KB Output is correct
16 Correct 178 ms 31324 KB Output is correct
17 Correct 73 ms 21084 KB Output is correct
18 Correct 156 ms 25236 KB Output is correct
19 Correct 133 ms 27292 KB Output is correct
20 Correct 196 ms 31324 KB Output is correct
21 Correct 815 ms 66276 KB Output is correct
22 Execution timed out 1081 ms 74332 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6604 KB Output is correct
2 Correct 11 ms 8848 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 5 ms 6748 KB Output is correct
5 Correct 39 ms 14980 KB Output is correct
6 Correct 22 ms 11052 KB Output is correct
7 Correct 14 ms 8796 KB Output is correct
8 Correct 32 ms 14976 KB Output is correct
9 Correct 25 ms 12892 KB Output is correct
10 Correct 199 ms 31396 KB Output is correct
11 Correct 185 ms 31396 KB Output is correct
12 Correct 184 ms 31392 KB Output is correct
13 Correct 147 ms 27292 KB Output is correct
14 Correct 167 ms 29344 KB Output is correct
15 Correct 202 ms 29340 KB Output is correct
16 Correct 178 ms 31324 KB Output is correct
17 Correct 73 ms 21084 KB Output is correct
18 Correct 156 ms 25236 KB Output is correct
19 Correct 133 ms 27292 KB Output is correct
20 Correct 196 ms 31324 KB Output is correct
21 Correct 815 ms 66276 KB Output is correct
22 Execution timed out 1081 ms 74332 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6604 KB Output is correct
2 Correct 11 ms 8848 KB Output is correct
3 Correct 4 ms 4700 KB Output is correct
4 Correct 5 ms 6748 KB Output is correct
5 Correct 39 ms 14980 KB Output is correct
6 Correct 22 ms 11052 KB Output is correct
7 Correct 14 ms 8796 KB Output is correct
8 Correct 32 ms 14976 KB Output is correct
9 Correct 25 ms 12892 KB Output is correct
10 Correct 199 ms 31396 KB Output is correct
11 Correct 185 ms 31396 KB Output is correct
12 Correct 184 ms 31392 KB Output is correct
13 Correct 147 ms 27292 KB Output is correct
14 Correct 167 ms 29344 KB Output is correct
15 Correct 202 ms 29340 KB Output is correct
16 Correct 178 ms 31324 KB Output is correct
17 Correct 73 ms 21084 KB Output is correct
18 Correct 156 ms 25236 KB Output is correct
19 Correct 133 ms 27292 KB Output is correct
20 Correct 196 ms 31324 KB Output is correct
21 Correct 815 ms 66276 KB Output is correct
22 Execution timed out 1081 ms 74332 KB Time limit exceeded
23 Halted 0 ms 0 KB -