Submission #930698

# Submission time Handle Problem Language Result Execution time Memory
930698 2024-02-20T09:40:28 Z allin27x Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 8280 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 502;

set<int> good;
set<int> ng;
set<int> nng;

int ar[MAXN];
int n;
bitset<MAXN * MAXN> kp;

void knap(int ind){
	kp.reset();
	kp.set(0);
	int s =0; for (int i=0; i<n; i++) if (i!= ind) s+=ar[i];
	for (int i=0; i<n; i++){
		if (i==ind) continue;
		kp |= kp<<ar[i];
	}
	ng.clear();
	for (int i=1; i<n*MAXN; i++){
		if (!kp[i]) continue;
		// i  = (s-i) + r
		if (2*i-s <= 0) continue;
		ng.insert(2*i-s);
	}
	nng.clear();
	for (int x: good) if (ng.count(x)) nng.insert(x);
	good = nng; 
}
int main(){
	cin>>n;
	for (int i=0; i<n; i++) cin>>ar[i];
	for (int i=1; i<n*MAXN; i++) good.insert(i);
	if (n&1) {cout<<0; exit(0);}
	int s=0; for (int i=0; i<n; i++) s += ar[i];
	kp.set(0);
	for (int i=0; i<n; i++){
		kp |= kp << ar[i];
	}
	if (!kp[s/2])  {cout<<0; exit(0);}
	for (int i=0; i<n; i++){
		knap(i);
	}
	cout<<good.size()<<'\n';
	for (int x: good) cout<<x<<' ';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 8 ms 1116 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 8 ms 1116 KB Output is correct
13 Correct 6 ms 1116 KB Output is correct
14 Correct 8 ms 1264 KB Output is correct
15 Correct 7 ms 1116 KB Output is correct
16 Correct 8 ms 1272 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 6 ms 1116 KB Output is correct
19 Correct 6 ms 1116 KB Output is correct
20 Correct 8 ms 1080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 8 ms 1116 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 8 ms 1116 KB Output is correct
13 Correct 6 ms 1116 KB Output is correct
14 Correct 8 ms 1264 KB Output is correct
15 Correct 7 ms 1116 KB Output is correct
16 Correct 8 ms 1272 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 6 ms 1116 KB Output is correct
19 Correct 6 ms 1116 KB Output is correct
20 Correct 8 ms 1080 KB Output is correct
21 Correct 57 ms 2220 KB Output is correct
22 Correct 62 ms 2484 KB Output is correct
23 Correct 29 ms 1880 KB Output is correct
24 Correct 108 ms 2996 KB Output is correct
25 Correct 122 ms 3108 KB Output is correct
26 Correct 138 ms 3160 KB Output is correct
27 Correct 110 ms 2912 KB Output is correct
28 Correct 99 ms 3104 KB Output is correct
29 Correct 96 ms 3132 KB Output is correct
30 Correct 86 ms 3164 KB Output is correct
31 Correct 145 ms 3164 KB Output is correct
32 Correct 118 ms 3136 KB Output is correct
33 Correct 71 ms 2908 KB Output is correct
34 Correct 70 ms 2908 KB Output is correct
35 Correct 80 ms 3108 KB Output is correct
36 Correct 116 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 8 ms 1116 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 8 ms 1116 KB Output is correct
13 Correct 6 ms 1116 KB Output is correct
14 Correct 8 ms 1264 KB Output is correct
15 Correct 7 ms 1116 KB Output is correct
16 Correct 8 ms 1272 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 6 ms 1116 KB Output is correct
19 Correct 6 ms 1116 KB Output is correct
20 Correct 8 ms 1080 KB Output is correct
21 Correct 57 ms 2220 KB Output is correct
22 Correct 62 ms 2484 KB Output is correct
23 Correct 29 ms 1880 KB Output is correct
24 Correct 108 ms 2996 KB Output is correct
25 Correct 122 ms 3108 KB Output is correct
26 Correct 138 ms 3160 KB Output is correct
27 Correct 110 ms 2912 KB Output is correct
28 Correct 99 ms 3104 KB Output is correct
29 Correct 96 ms 3132 KB Output is correct
30 Correct 86 ms 3164 KB Output is correct
31 Correct 145 ms 3164 KB Output is correct
32 Correct 118 ms 3136 KB Output is correct
33 Correct 71 ms 2908 KB Output is correct
34 Correct 70 ms 2908 KB Output is correct
35 Correct 80 ms 3108 KB Output is correct
36 Correct 116 ms 2908 KB Output is correct
37 Correct 790 ms 6180 KB Output is correct
38 Correct 783 ms 6228 KB Output is correct
39 Correct 428 ms 6424 KB Output is correct
40 Execution timed out 1046 ms 8280 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 8 ms 1116 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 8 ms 1116 KB Output is correct
13 Correct 6 ms 1116 KB Output is correct
14 Correct 8 ms 1264 KB Output is correct
15 Correct 7 ms 1116 KB Output is correct
16 Correct 8 ms 1272 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 6 ms 1116 KB Output is correct
19 Correct 6 ms 1116 KB Output is correct
20 Correct 8 ms 1080 KB Output is correct
21 Correct 57 ms 2220 KB Output is correct
22 Correct 62 ms 2484 KB Output is correct
23 Correct 29 ms 1880 KB Output is correct
24 Correct 108 ms 2996 KB Output is correct
25 Correct 122 ms 3108 KB Output is correct
26 Correct 138 ms 3160 KB Output is correct
27 Correct 110 ms 2912 KB Output is correct
28 Correct 99 ms 3104 KB Output is correct
29 Correct 96 ms 3132 KB Output is correct
30 Correct 86 ms 3164 KB Output is correct
31 Correct 145 ms 3164 KB Output is correct
32 Correct 118 ms 3136 KB Output is correct
33 Correct 71 ms 2908 KB Output is correct
34 Correct 70 ms 2908 KB Output is correct
35 Correct 80 ms 3108 KB Output is correct
36 Correct 116 ms 2908 KB Output is correct
37 Correct 790 ms 6180 KB Output is correct
38 Correct 783 ms 6228 KB Output is correct
39 Correct 428 ms 6424 KB Output is correct
40 Execution timed out 1046 ms 8280 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 496 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 8 ms 1116 KB Output is correct
11 Correct 9 ms 1116 KB Output is correct
12 Correct 8 ms 1116 KB Output is correct
13 Correct 6 ms 1116 KB Output is correct
14 Correct 8 ms 1264 KB Output is correct
15 Correct 7 ms 1116 KB Output is correct
16 Correct 8 ms 1272 KB Output is correct
17 Correct 4 ms 860 KB Output is correct
18 Correct 6 ms 1116 KB Output is correct
19 Correct 6 ms 1116 KB Output is correct
20 Correct 8 ms 1080 KB Output is correct
21 Correct 57 ms 2220 KB Output is correct
22 Correct 62 ms 2484 KB Output is correct
23 Correct 29 ms 1880 KB Output is correct
24 Correct 108 ms 2996 KB Output is correct
25 Correct 122 ms 3108 KB Output is correct
26 Correct 138 ms 3160 KB Output is correct
27 Correct 110 ms 2912 KB Output is correct
28 Correct 99 ms 3104 KB Output is correct
29 Correct 96 ms 3132 KB Output is correct
30 Correct 86 ms 3164 KB Output is correct
31 Correct 145 ms 3164 KB Output is correct
32 Correct 118 ms 3136 KB Output is correct
33 Correct 71 ms 2908 KB Output is correct
34 Correct 70 ms 2908 KB Output is correct
35 Correct 80 ms 3108 KB Output is correct
36 Correct 116 ms 2908 KB Output is correct
37 Correct 790 ms 6180 KB Output is correct
38 Correct 783 ms 6228 KB Output is correct
39 Correct 428 ms 6424 KB Output is correct
40 Execution timed out 1046 ms 8280 KB Time limit exceeded
41 Halted 0 ms 0 KB -