Submission #930709

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

const int MAXN = 502;

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

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];
	}
	for (int i: obtainable){
		if (!kp[i]) continue;
		if (2*i-s <= 0) continue;
		g[2*i-s] ++;
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	for (int i=0; i<n; i++) cin>>ar[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];
	}
	for (int i=0; i<MAXN*MAXN; i++){
		if (kp[i]) obtainable.push_back(i);
	}
	if (!kp[s/2])  {cout<<0; exit(0);}
	for (int i=0; i<n; i++){
		knap(i);
	}
	set<int> good;
	for (int i=1; i<MAXN*MAXN; i++) if (g[i] == n) good.insert(i);
	cout<<good.size()<<'\n';
	for (int x: good) cout<<x<<' ';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 604 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 6 ms 868 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 4 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 604 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 6 ms 868 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 4 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 612 KB Output is correct
21 Correct 25 ms 600 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 17 ms 648 KB Output is correct
24 Correct 54 ms 664 KB Output is correct
25 Correct 55 ms 700 KB Output is correct
26 Correct 69 ms 684 KB Output is correct
27 Correct 59 ms 600 KB Output is correct
28 Correct 60 ms 656 KB Output is correct
29 Correct 71 ms 696 KB Output is correct
30 Correct 60 ms 604 KB Output is correct
31 Correct 71 ms 848 KB Output is correct
32 Correct 97 ms 664 KB Output is correct
33 Correct 58 ms 624 KB Output is correct
34 Correct 59 ms 604 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 69 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 604 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 6 ms 868 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 4 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 612 KB Output is correct
21 Correct 25 ms 600 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 17 ms 648 KB Output is correct
24 Correct 54 ms 664 KB Output is correct
25 Correct 55 ms 700 KB Output is correct
26 Correct 69 ms 684 KB Output is correct
27 Correct 59 ms 600 KB Output is correct
28 Correct 60 ms 656 KB Output is correct
29 Correct 71 ms 696 KB Output is correct
30 Correct 60 ms 604 KB Output is correct
31 Correct 71 ms 848 KB Output is correct
32 Correct 97 ms 664 KB Output is correct
33 Correct 58 ms 624 KB Output is correct
34 Correct 59 ms 604 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 69 ms 664 KB Output is correct
37 Correct 254 ms 1128 KB Output is correct
38 Correct 234 ms 1108 KB Output is correct
39 Correct 349 ms 852 KB Output is correct
40 Correct 432 ms 1624 KB Output is correct
41 Correct 459 ms 876 KB Output is correct
42 Correct 373 ms 1360 KB Output is correct
43 Correct 362 ms 2176 KB Output is correct
44 Correct 377 ms 2276 KB Output is correct
45 Correct 389 ms 2288 KB Output is correct
46 Correct 432 ms 860 KB Output is correct
47 Correct 380 ms 1616 KB Output is correct
48 Correct 384 ms 1924 KB Output is correct
49 Correct 367 ms 1068 KB Output is correct
50 Correct 381 ms 1484 KB Output is correct
51 Correct 371 ms 856 KB Output is correct
52 Correct 449 ms 2532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 604 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 6 ms 868 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 4 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 612 KB Output is correct
21 Correct 25 ms 600 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 17 ms 648 KB Output is correct
24 Correct 54 ms 664 KB Output is correct
25 Correct 55 ms 700 KB Output is correct
26 Correct 69 ms 684 KB Output is correct
27 Correct 59 ms 600 KB Output is correct
28 Correct 60 ms 656 KB Output is correct
29 Correct 71 ms 696 KB Output is correct
30 Correct 60 ms 604 KB Output is correct
31 Correct 71 ms 848 KB Output is correct
32 Correct 97 ms 664 KB Output is correct
33 Correct 58 ms 624 KB Output is correct
34 Correct 59 ms 604 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 69 ms 664 KB Output is correct
37 Correct 254 ms 1128 KB Output is correct
38 Correct 234 ms 1108 KB Output is correct
39 Correct 349 ms 852 KB Output is correct
40 Correct 432 ms 1624 KB Output is correct
41 Correct 459 ms 876 KB Output is correct
42 Correct 373 ms 1360 KB Output is correct
43 Correct 362 ms 2176 KB Output is correct
44 Correct 377 ms 2276 KB Output is correct
45 Correct 389 ms 2288 KB Output is correct
46 Correct 432 ms 860 KB Output is correct
47 Correct 380 ms 1616 KB Output is correct
48 Correct 384 ms 1924 KB Output is correct
49 Correct 367 ms 1068 KB Output is correct
50 Correct 381 ms 1484 KB Output is correct
51 Correct 371 ms 856 KB Output is correct
52 Correct 449 ms 2532 KB Output is correct
53 Correct 555 ms 2004 KB Output is correct
54 Correct 727 ms 2264 KB Output is correct
55 Correct 750 ms 3884 KB Output is correct
56 Correct 558 ms 2448 KB Output is correct
57 Correct 749 ms 4308 KB Output is correct
58 Correct 759 ms 2488 KB Output is correct
59 Correct 800 ms 3120 KB Output is correct
60 Correct 759 ms 992 KB Output is correct
61 Correct 759 ms 3448 KB Output is correct
62 Correct 639 ms 3772 KB Output is correct
63 Correct 664 ms 3828 KB Output is correct
64 Correct 617 ms 3840 KB Output is correct
65 Correct 588 ms 848 KB Output is correct
66 Correct 554 ms 904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 856 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 604 KB Output is correct
13 Correct 5 ms 604 KB Output is correct
14 Correct 6 ms 868 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 4 ms 604 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 612 KB Output is correct
21 Correct 25 ms 600 KB Output is correct
22 Correct 34 ms 604 KB Output is correct
23 Correct 17 ms 648 KB Output is correct
24 Correct 54 ms 664 KB Output is correct
25 Correct 55 ms 700 KB Output is correct
26 Correct 69 ms 684 KB Output is correct
27 Correct 59 ms 600 KB Output is correct
28 Correct 60 ms 656 KB Output is correct
29 Correct 71 ms 696 KB Output is correct
30 Correct 60 ms 604 KB Output is correct
31 Correct 71 ms 848 KB Output is correct
32 Correct 97 ms 664 KB Output is correct
33 Correct 58 ms 624 KB Output is correct
34 Correct 59 ms 604 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 69 ms 664 KB Output is correct
37 Correct 254 ms 1128 KB Output is correct
38 Correct 234 ms 1108 KB Output is correct
39 Correct 349 ms 852 KB Output is correct
40 Correct 432 ms 1624 KB Output is correct
41 Correct 459 ms 876 KB Output is correct
42 Correct 373 ms 1360 KB Output is correct
43 Correct 362 ms 2176 KB Output is correct
44 Correct 377 ms 2276 KB Output is correct
45 Correct 389 ms 2288 KB Output is correct
46 Correct 432 ms 860 KB Output is correct
47 Correct 380 ms 1616 KB Output is correct
48 Correct 384 ms 1924 KB Output is correct
49 Correct 367 ms 1068 KB Output is correct
50 Correct 381 ms 1484 KB Output is correct
51 Correct 371 ms 856 KB Output is correct
52 Correct 449 ms 2532 KB Output is correct
53 Correct 555 ms 2004 KB Output is correct
54 Correct 727 ms 2264 KB Output is correct
55 Correct 750 ms 3884 KB Output is correct
56 Correct 558 ms 2448 KB Output is correct
57 Correct 749 ms 4308 KB Output is correct
58 Correct 759 ms 2488 KB Output is correct
59 Correct 800 ms 3120 KB Output is correct
60 Correct 759 ms 992 KB Output is correct
61 Correct 759 ms 3448 KB Output is correct
62 Correct 639 ms 3772 KB Output is correct
63 Correct 664 ms 3828 KB Output is correct
64 Correct 617 ms 3840 KB Output is correct
65 Correct 588 ms 848 KB Output is correct
66 Correct 554 ms 904 KB Output is correct
67 Execution timed out 1004 ms 3156 KB Time limit exceeded
68 Halted 0 ms 0 KB -