Submission #661101

# Submission time Handle Problem Language Result Execution time Memory
661101 2022-11-24T11:52:01 Z Kaztaev_Alisher Bootfall (IZhO17_bootfall) C++17
65 / 100
194 ms 262144 KB
//#pragma GCC optomize ("Ofast")
//#pragma GCC optomize ("unroll-loops")
//#pragma GCC target ("avx,avx2,fma")

#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size
#define cl clear
#define ins insert
#define ers erase
#define pii pair < int , int >
#define pll pair< long long  , long long >
#define all(x) x.begin() , x.end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define tostr(x) to_string(x)
#define tonum(s) atoi(s.c_str())
#define seon(x) setprecision(x)
#define bpop(x) __builtin_popcount(x)
#define deb(x) cerr << #x  << " = " << x << endl;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
const double PI = 3.14159265;

const ll N = 500+9 , M = 500*500+1;
const ll mod = 1e9+7;
const ll inf = 1e9;
const ll INF = 1e18;

using namespace std;

int dp[N][M];
int a[N];
vector<int> ans;

void solve(){
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n ; i++) {
		cin >> a[i];
		sum += a[i];
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n ; i++) {
		for(int j = sum; j >= a[i]; j--){
			dp[0][j] += dp[0][j-a[i]];
		}
	}
	if(sum % 2 == 1 || dp[0][(sum>>1)] == 0){
		cout << 0;
		return;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= sum; j++) dp[i][j] = dp[0][j];
		for(int j = a[i]; j <= sum; j++) dp[i][j] -= dp[i][j-a[i]];
	}
	for(int i = 1; i <= sum; i++){
		int cnt = 0;
		for(int j = 1; j <= n; j++){
			int ob = sum-a[j]+i;
			if(ob % 2 == 0 && dp[j][ob/2-i]) cnt++;
		}
		if(cnt==n) ans.pb(i);
	}
	cout << ans.sz() <<"\n";
	for(int x : ans) cout << x <<" ";
}
signed main(){
	ios;
	solve();
	return 0;
}
/*
*/
 	
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 2 ms 2516 KB Output is correct
25 Correct 4 ms 4180 KB Output is correct
26 Correct 5 ms 4632 KB Output is correct
27 Correct 5 ms 4416 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 4 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 6 ms 4868 KB Output is correct
34 Correct 5 ms 4820 KB Output is correct
35 Correct 5 ms 4748 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 2 ms 2516 KB Output is correct
25 Correct 4 ms 4180 KB Output is correct
26 Correct 5 ms 4632 KB Output is correct
27 Correct 5 ms 4416 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 4 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 6 ms 4868 KB Output is correct
34 Correct 5 ms 4820 KB Output is correct
35 Correct 5 ms 4748 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 19 ms 16796 KB Output is correct
38 Correct 20 ms 17188 KB Output is correct
39 Correct 65 ms 61844 KB Output is correct
40 Correct 38 ms 36356 KB Output is correct
41 Correct 81 ms 79092 KB Output is correct
42 Correct 38 ms 31496 KB Output is correct
43 Correct 62 ms 54768 KB Output is correct
44 Correct 60 ms 56652 KB Output is correct
45 Correct 61 ms 57640 KB Output is correct
46 Correct 37 ms 35264 KB Output is correct
47 Correct 36 ms 33844 KB Output is correct
48 Correct 71 ms 62080 KB Output is correct
49 Correct 65 ms 62320 KB Output is correct
50 Correct 45 ms 33988 KB Output is correct
51 Correct 4 ms 452 KB Output is correct
52 Correct 79 ms 76364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 2 ms 2516 KB Output is correct
25 Correct 4 ms 4180 KB Output is correct
26 Correct 5 ms 4632 KB Output is correct
27 Correct 5 ms 4416 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 4 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 6 ms 4868 KB Output is correct
34 Correct 5 ms 4820 KB Output is correct
35 Correct 5 ms 4748 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 19 ms 16796 KB Output is correct
38 Correct 20 ms 17188 KB Output is correct
39 Correct 65 ms 61844 KB Output is correct
40 Correct 38 ms 36356 KB Output is correct
41 Correct 81 ms 79092 KB Output is correct
42 Correct 38 ms 31496 KB Output is correct
43 Correct 62 ms 54768 KB Output is correct
44 Correct 60 ms 56652 KB Output is correct
45 Correct 61 ms 57640 KB Output is correct
46 Correct 37 ms 35264 KB Output is correct
47 Correct 36 ms 33844 KB Output is correct
48 Correct 71 ms 62080 KB Output is correct
49 Correct 65 ms 62320 KB Output is correct
50 Correct 45 ms 33988 KB Output is correct
51 Correct 4 ms 452 KB Output is correct
52 Correct 79 ms 76364 KB Output is correct
53 Correct 60 ms 55904 KB Output is correct
54 Correct 80 ms 78832 KB Output is correct
55 Correct 161 ms 155040 KB Output is correct
56 Correct 72 ms 69196 KB Output is correct
57 Correct 163 ms 163436 KB Output is correct
58 Correct 88 ms 86580 KB Output is correct
59 Correct 147 ms 107632 KB Output is correct
60 Correct 10 ms 468 KB Output is correct
61 Correct 123 ms 120348 KB Output is correct
62 Correct 126 ms 122832 KB Output is correct
63 Correct 155 ms 132768 KB Output is correct
64 Correct 161 ms 128564 KB Output is correct
65 Correct 63 ms 61608 KB Output is correct
66 Correct 68 ms 66632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 0 ms 468 KB Output is correct
16 Correct 0 ms 468 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 1492 KB Output is correct
22 Correct 2 ms 1748 KB Output is correct
23 Correct 2 ms 1108 KB Output is correct
24 Correct 2 ms 2516 KB Output is correct
25 Correct 4 ms 4180 KB Output is correct
26 Correct 5 ms 4632 KB Output is correct
27 Correct 5 ms 4416 KB Output is correct
28 Correct 5 ms 4564 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 3 ms 2900 KB Output is correct
31 Correct 4 ms 3924 KB Output is correct
32 Correct 3 ms 2772 KB Output is correct
33 Correct 6 ms 4868 KB Output is correct
34 Correct 5 ms 4820 KB Output is correct
35 Correct 5 ms 4748 KB Output is correct
36 Correct 3 ms 2772 KB Output is correct
37 Correct 19 ms 16796 KB Output is correct
38 Correct 20 ms 17188 KB Output is correct
39 Correct 65 ms 61844 KB Output is correct
40 Correct 38 ms 36356 KB Output is correct
41 Correct 81 ms 79092 KB Output is correct
42 Correct 38 ms 31496 KB Output is correct
43 Correct 62 ms 54768 KB Output is correct
44 Correct 60 ms 56652 KB Output is correct
45 Correct 61 ms 57640 KB Output is correct
46 Correct 37 ms 35264 KB Output is correct
47 Correct 36 ms 33844 KB Output is correct
48 Correct 71 ms 62080 KB Output is correct
49 Correct 65 ms 62320 KB Output is correct
50 Correct 45 ms 33988 KB Output is correct
51 Correct 4 ms 452 KB Output is correct
52 Correct 79 ms 76364 KB Output is correct
53 Correct 60 ms 55904 KB Output is correct
54 Correct 80 ms 78832 KB Output is correct
55 Correct 161 ms 155040 KB Output is correct
56 Correct 72 ms 69196 KB Output is correct
57 Correct 163 ms 163436 KB Output is correct
58 Correct 88 ms 86580 KB Output is correct
59 Correct 147 ms 107632 KB Output is correct
60 Correct 10 ms 468 KB Output is correct
61 Correct 123 ms 120348 KB Output is correct
62 Correct 126 ms 122832 KB Output is correct
63 Correct 155 ms 132768 KB Output is correct
64 Correct 161 ms 128564 KB Output is correct
65 Correct 63 ms 61608 KB Output is correct
66 Correct 68 ms 66632 KB Output is correct
67 Correct 135 ms 128464 KB Output is correct
68 Correct 31 ms 724 KB Output is correct
69 Runtime error 194 ms 262144 KB Execution killed with signal 9
70 Halted 0 ms 0 KB -