Submission #906885

# Submission time Handle Problem Language Result Execution time Memory
906885 2024-01-15T04:30:45 Z daoquanglinh2007 Bootfall (IZhO17_bootfall) C++17
100 / 100
529 ms 5208 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int NM = 500, MOD = 1e15+7;

int N, a[NM+5], sum = 0, dp[NM*NM+5], dp0[NM*NM+5], K = 0;
bool ok[NM*NM+5];

void add(int x){
	for (int i = NM*NM; i >= x; i--)
		dp[i] = (dp[i]+dp[i-x])%MOD;
}

void remove(int x){
	for (int i = x; i <= NM*NM; i++)
		dp[i] = (dp[i]+MOD-dp[i-x])%MOD;
}

void solve(int t){
	for (int i = 0; i <= NM*NM; i++) dp[i] = dp0[i];
	remove(a[t]);
	
	for (int i = 1; i <= NM*NM; i++)
		if ((sum-a[t]+i)%2 != 0 || (sum-a[t]+i)/2-i < 0 || !dp[(sum-a[t]+i)/2-i]) ok[i] = 0;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	dp[0] = 1;
	for (int i = 1; i <= N; i++){
		cin >> a[i];
		sum += a[i];
		add(a[i]);
	}
	if (sum%2 != 0 || !dp[sum/2]){
		cout << "0\n";
		return 0;
	}
	for (int i = 0; i <= NM*NM; i++){
		dp0[i] = dp[i];
		ok[i] = 1;
	}
	for (int i = 1; i <= N; i++)
		solve(i);
		
	for (int i = 1; i <= NM*NM; i++) K += ok[i];
	
	cout << K << '\n';
	for (int i = 1; i <= NM*NM; i++)
		if (ok[i]) cout << i << ' ';
		
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4612 KB Output is correct
2 Correct 11 ms 4440 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 6 ms 4440 KB Output is correct
5 Correct 14 ms 4444 KB Output is correct
6 Correct 10 ms 4440 KB Output is correct
7 Correct 12 ms 4444 KB Output is correct
8 Correct 15 ms 4440 KB Output is correct
9 Correct 12 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4612 KB Output is correct
2 Correct 11 ms 4440 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 6 ms 4440 KB Output is correct
5 Correct 14 ms 4444 KB Output is correct
6 Correct 10 ms 4440 KB Output is correct
7 Correct 12 ms 4444 KB Output is correct
8 Correct 15 ms 4440 KB Output is correct
9 Correct 12 ms 4444 KB Output is correct
10 Correct 28 ms 4440 KB Output is correct
11 Correct 40 ms 4608 KB Output is correct
12 Correct 29 ms 4616 KB Output is correct
13 Correct 26 ms 4436 KB Output is correct
14 Correct 29 ms 4604 KB Output is correct
15 Correct 42 ms 4440 KB Output is correct
16 Correct 52 ms 4440 KB Output is correct
17 Correct 24 ms 4596 KB Output is correct
18 Correct 26 ms 4444 KB Output is correct
19 Correct 30 ms 4444 KB Output is correct
20 Correct 29 ms 4616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4612 KB Output is correct
2 Correct 11 ms 4440 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 6 ms 4440 KB Output is correct
5 Correct 14 ms 4444 KB Output is correct
6 Correct 10 ms 4440 KB Output is correct
7 Correct 12 ms 4444 KB Output is correct
8 Correct 15 ms 4440 KB Output is correct
9 Correct 12 ms 4444 KB Output is correct
10 Correct 28 ms 4440 KB Output is correct
11 Correct 40 ms 4608 KB Output is correct
12 Correct 29 ms 4616 KB Output is correct
13 Correct 26 ms 4436 KB Output is correct
14 Correct 29 ms 4604 KB Output is correct
15 Correct 42 ms 4440 KB Output is correct
16 Correct 52 ms 4440 KB Output is correct
17 Correct 24 ms 4596 KB Output is correct
18 Correct 26 ms 4444 KB Output is correct
19 Correct 30 ms 4444 KB Output is correct
20 Correct 29 ms 4616 KB Output is correct
21 Correct 67 ms 4592 KB Output is correct
22 Correct 76 ms 4440 KB Output is correct
23 Correct 53 ms 4596 KB Output is correct
24 Correct 88 ms 4432 KB Output is correct
25 Correct 111 ms 4432 KB Output is correct
26 Correct 128 ms 4424 KB Output is correct
27 Correct 120 ms 4592 KB Output is correct
28 Correct 116 ms 4432 KB Output is correct
29 Correct 97 ms 4592 KB Output is correct
30 Correct 94 ms 4592 KB Output is correct
31 Correct 102 ms 4412 KB Output is correct
32 Correct 94 ms 4600 KB Output is correct
33 Correct 88 ms 4444 KB Output is correct
34 Correct 92 ms 4592 KB Output is correct
35 Correct 155 ms 4592 KB Output is correct
36 Correct 97 ms 4432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4612 KB Output is correct
2 Correct 11 ms 4440 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 6 ms 4440 KB Output is correct
5 Correct 14 ms 4444 KB Output is correct
6 Correct 10 ms 4440 KB Output is correct
7 Correct 12 ms 4444 KB Output is correct
8 Correct 15 ms 4440 KB Output is correct
9 Correct 12 ms 4444 KB Output is correct
10 Correct 28 ms 4440 KB Output is correct
11 Correct 40 ms 4608 KB Output is correct
12 Correct 29 ms 4616 KB Output is correct
13 Correct 26 ms 4436 KB Output is correct
14 Correct 29 ms 4604 KB Output is correct
15 Correct 42 ms 4440 KB Output is correct
16 Correct 52 ms 4440 KB Output is correct
17 Correct 24 ms 4596 KB Output is correct
18 Correct 26 ms 4444 KB Output is correct
19 Correct 30 ms 4444 KB Output is correct
20 Correct 29 ms 4616 KB Output is correct
21 Correct 67 ms 4592 KB Output is correct
22 Correct 76 ms 4440 KB Output is correct
23 Correct 53 ms 4596 KB Output is correct
24 Correct 88 ms 4432 KB Output is correct
25 Correct 111 ms 4432 KB Output is correct
26 Correct 128 ms 4424 KB Output is correct
27 Correct 120 ms 4592 KB Output is correct
28 Correct 116 ms 4432 KB Output is correct
29 Correct 97 ms 4592 KB Output is correct
30 Correct 94 ms 4592 KB Output is correct
31 Correct 102 ms 4412 KB Output is correct
32 Correct 94 ms 4600 KB Output is correct
33 Correct 88 ms 4444 KB Output is correct
34 Correct 92 ms 4592 KB Output is correct
35 Correct 155 ms 4592 KB Output is correct
36 Correct 97 ms 4432 KB Output is correct
37 Correct 187 ms 4592 KB Output is correct
38 Correct 208 ms 4680 KB Output is correct
39 Correct 239 ms 4436 KB Output is correct
40 Correct 313 ms 4588 KB Output is correct
41 Correct 272 ms 4596 KB Output is correct
42 Correct 243 ms 4432 KB Output is correct
43 Correct 236 ms 4588 KB Output is correct
44 Correct 238 ms 4680 KB Output is correct
45 Correct 224 ms 4688 KB Output is correct
46 Correct 350 ms 4592 KB Output is correct
47 Correct 236 ms 4436 KB Output is correct
48 Correct 246 ms 4692 KB Output is correct
49 Correct 256 ms 4436 KB Output is correct
50 Correct 230 ms 4592 KB Output is correct
51 Correct 81 ms 4408 KB Output is correct
52 Correct 254 ms 4692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4612 KB Output is correct
2 Correct 11 ms 4440 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 6 ms 4440 KB Output is correct
5 Correct 14 ms 4444 KB Output is correct
6 Correct 10 ms 4440 KB Output is correct
7 Correct 12 ms 4444 KB Output is correct
8 Correct 15 ms 4440 KB Output is correct
9 Correct 12 ms 4444 KB Output is correct
10 Correct 28 ms 4440 KB Output is correct
11 Correct 40 ms 4608 KB Output is correct
12 Correct 29 ms 4616 KB Output is correct
13 Correct 26 ms 4436 KB Output is correct
14 Correct 29 ms 4604 KB Output is correct
15 Correct 42 ms 4440 KB Output is correct
16 Correct 52 ms 4440 KB Output is correct
17 Correct 24 ms 4596 KB Output is correct
18 Correct 26 ms 4444 KB Output is correct
19 Correct 30 ms 4444 KB Output is correct
20 Correct 29 ms 4616 KB Output is correct
21 Correct 67 ms 4592 KB Output is correct
22 Correct 76 ms 4440 KB Output is correct
23 Correct 53 ms 4596 KB Output is correct
24 Correct 88 ms 4432 KB Output is correct
25 Correct 111 ms 4432 KB Output is correct
26 Correct 128 ms 4424 KB Output is correct
27 Correct 120 ms 4592 KB Output is correct
28 Correct 116 ms 4432 KB Output is correct
29 Correct 97 ms 4592 KB Output is correct
30 Correct 94 ms 4592 KB Output is correct
31 Correct 102 ms 4412 KB Output is correct
32 Correct 94 ms 4600 KB Output is correct
33 Correct 88 ms 4444 KB Output is correct
34 Correct 92 ms 4592 KB Output is correct
35 Correct 155 ms 4592 KB Output is correct
36 Correct 97 ms 4432 KB Output is correct
37 Correct 187 ms 4592 KB Output is correct
38 Correct 208 ms 4680 KB Output is correct
39 Correct 239 ms 4436 KB Output is correct
40 Correct 313 ms 4588 KB Output is correct
41 Correct 272 ms 4596 KB Output is correct
42 Correct 243 ms 4432 KB Output is correct
43 Correct 236 ms 4588 KB Output is correct
44 Correct 238 ms 4680 KB Output is correct
45 Correct 224 ms 4688 KB Output is correct
46 Correct 350 ms 4592 KB Output is correct
47 Correct 236 ms 4436 KB Output is correct
48 Correct 246 ms 4692 KB Output is correct
49 Correct 256 ms 4436 KB Output is correct
50 Correct 230 ms 4592 KB Output is correct
51 Correct 81 ms 4408 KB Output is correct
52 Correct 254 ms 4692 KB Output is correct
53 Correct 286 ms 4592 KB Output is correct
54 Correct 529 ms 4588 KB Output is correct
55 Correct 343 ms 4844 KB Output is correct
56 Correct 299 ms 4680 KB Output is correct
57 Correct 331 ms 4688 KB Output is correct
58 Correct 326 ms 4592 KB Output is correct
59 Correct 385 ms 4588 KB Output is correct
60 Correct 110 ms 4412 KB Output is correct
61 Correct 325 ms 4668 KB Output is correct
62 Correct 312 ms 4948 KB Output is correct
63 Correct 299 ms 4696 KB Output is correct
64 Correct 316 ms 4692 KB Output is correct
65 Correct 285 ms 4432 KB Output is correct
66 Correct 296 ms 4604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4612 KB Output is correct
2 Correct 11 ms 4440 KB Output is correct
3 Correct 4 ms 4188 KB Output is correct
4 Correct 6 ms 4440 KB Output is correct
5 Correct 14 ms 4444 KB Output is correct
6 Correct 10 ms 4440 KB Output is correct
7 Correct 12 ms 4444 KB Output is correct
8 Correct 15 ms 4440 KB Output is correct
9 Correct 12 ms 4444 KB Output is correct
10 Correct 28 ms 4440 KB Output is correct
11 Correct 40 ms 4608 KB Output is correct
12 Correct 29 ms 4616 KB Output is correct
13 Correct 26 ms 4436 KB Output is correct
14 Correct 29 ms 4604 KB Output is correct
15 Correct 42 ms 4440 KB Output is correct
16 Correct 52 ms 4440 KB Output is correct
17 Correct 24 ms 4596 KB Output is correct
18 Correct 26 ms 4444 KB Output is correct
19 Correct 30 ms 4444 KB Output is correct
20 Correct 29 ms 4616 KB Output is correct
21 Correct 67 ms 4592 KB Output is correct
22 Correct 76 ms 4440 KB Output is correct
23 Correct 53 ms 4596 KB Output is correct
24 Correct 88 ms 4432 KB Output is correct
25 Correct 111 ms 4432 KB Output is correct
26 Correct 128 ms 4424 KB Output is correct
27 Correct 120 ms 4592 KB Output is correct
28 Correct 116 ms 4432 KB Output is correct
29 Correct 97 ms 4592 KB Output is correct
30 Correct 94 ms 4592 KB Output is correct
31 Correct 102 ms 4412 KB Output is correct
32 Correct 94 ms 4600 KB Output is correct
33 Correct 88 ms 4444 KB Output is correct
34 Correct 92 ms 4592 KB Output is correct
35 Correct 155 ms 4592 KB Output is correct
36 Correct 97 ms 4432 KB Output is correct
37 Correct 187 ms 4592 KB Output is correct
38 Correct 208 ms 4680 KB Output is correct
39 Correct 239 ms 4436 KB Output is correct
40 Correct 313 ms 4588 KB Output is correct
41 Correct 272 ms 4596 KB Output is correct
42 Correct 243 ms 4432 KB Output is correct
43 Correct 236 ms 4588 KB Output is correct
44 Correct 238 ms 4680 KB Output is correct
45 Correct 224 ms 4688 KB Output is correct
46 Correct 350 ms 4592 KB Output is correct
47 Correct 236 ms 4436 KB Output is correct
48 Correct 246 ms 4692 KB Output is correct
49 Correct 256 ms 4436 KB Output is correct
50 Correct 230 ms 4592 KB Output is correct
51 Correct 81 ms 4408 KB Output is correct
52 Correct 254 ms 4692 KB Output is correct
53 Correct 286 ms 4592 KB Output is correct
54 Correct 529 ms 4588 KB Output is correct
55 Correct 343 ms 4844 KB Output is correct
56 Correct 299 ms 4680 KB Output is correct
57 Correct 331 ms 4688 KB Output is correct
58 Correct 326 ms 4592 KB Output is correct
59 Correct 385 ms 4588 KB Output is correct
60 Correct 110 ms 4412 KB Output is correct
61 Correct 325 ms 4668 KB Output is correct
62 Correct 312 ms 4948 KB Output is correct
63 Correct 299 ms 4696 KB Output is correct
64 Correct 316 ms 4692 KB Output is correct
65 Correct 285 ms 4432 KB Output is correct
66 Correct 296 ms 4604 KB Output is correct
67 Correct 389 ms 4664 KB Output is correct
68 Correct 165 ms 4416 KB Output is correct
69 Correct 498 ms 5132 KB Output is correct
70 Correct 487 ms 4852 KB Output is correct
71 Correct 461 ms 4844 KB Output is correct
72 Correct 477 ms 4428 KB Output is correct
73 Correct 496 ms 4596 KB Output is correct
74 Correct 466 ms 5108 KB Output is correct
75 Correct 498 ms 5112 KB Output is correct
76 Correct 490 ms 5196 KB Output is correct
77 Correct 500 ms 5208 KB Output is correct