Submission #696988

# Submission time Handle Problem Language Result Execution time Memory
696988 2023-02-07T20:31:07 Z allllekssssa Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 11776 KB
#include<bits/stdc++.h>
 
using namespace std;
 
const int maxN = 350 + 5;
const int bsSize = maxN * maxN + 10;
int n;
int a[maxN];
bitset<bsSize> dp[2][maxN];
 
int main() {
 
	cin >> n;
    
	int sum = 0;
 
	for (int i = 1; i<=n; i++) {
		cin >> a[i];
		sum+=a[i];
	}
 
	for (int i = 1; i <= n + 1; i++) {
		dp[0][i].set(0);
	}
 
	for (int i = 1; i<=n; i++) {
		for (int j = 1; j <= n + 1; j++) {
			if (i == j) {
				dp[i&1][j] = dp[(i&1) ^ 1][j];
			} else {
				dp[i&1][j] = dp[(i&1) ^ 1][j] | (dp[(i&1) ^ 1][j] << a[i]);
			}
		}
 
		for (int j = 1; j<= n + 1; j++) {
			dp[(i - 1)&1][j].reset();
		}
	}
 
	if (dp[n&1][n + 1][sum/2] == 0) {
		printf("0\n");
		return 0;
	}
    
    vector<int> ans;
 
	for (int i = 1; i <= sum; i++) {
		bool ok = true;
         
        for (int j = 1; j<= n; j++) {
        	int totSum = sum  - a[j] + i;
        	if (totSum % 2 == 1) ok = false;
        	if (dp[n&1][j][totSum/2] == 0) ok = false;
        }
 
		if (ok) ans.push_back(i);
	}
 
	cout << ans.size() << endl;
 
	for (int i:ans) {
		cout << i << " ";
	}
 
	cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 6 ms 1236 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 4 ms 1184 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 4 ms 1236 KB Output is correct
16 Correct 5 ms 1300 KB Output is correct
17 Correct 2 ms 852 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 4 ms 1108 KB Output is correct
20 Correct 5 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 6 ms 1236 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 4 ms 1184 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 4 ms 1236 KB Output is correct
16 Correct 5 ms 1300 KB Output is correct
17 Correct 2 ms 852 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 4 ms 1108 KB Output is correct
20 Correct 5 ms 1236 KB Output is correct
21 Correct 20 ms 2260 KB Output is correct
22 Correct 29 ms 2644 KB Output is correct
23 Correct 12 ms 1912 KB Output is correct
24 Correct 42 ms 3260 KB Output is correct
25 Correct 51 ms 3252 KB Output is correct
26 Correct 50 ms 3412 KB Output is correct
27 Correct 49 ms 3444 KB Output is correct
28 Correct 49 ms 3444 KB Output is correct
29 Correct 52 ms 3436 KB Output is correct
30 Correct 48 ms 3432 KB Output is correct
31 Correct 51 ms 3444 KB Output is correct
32 Correct 50 ms 3436 KB Output is correct
33 Correct 52 ms 3412 KB Output is correct
34 Correct 49 ms 3436 KB Output is correct
35 Correct 50 ms 3428 KB Output is correct
36 Correct 47 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 6 ms 1236 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 4 ms 1184 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 4 ms 1236 KB Output is correct
16 Correct 5 ms 1300 KB Output is correct
17 Correct 2 ms 852 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 4 ms 1108 KB Output is correct
20 Correct 5 ms 1236 KB Output is correct
21 Correct 20 ms 2260 KB Output is correct
22 Correct 29 ms 2644 KB Output is correct
23 Correct 12 ms 1912 KB Output is correct
24 Correct 42 ms 3260 KB Output is correct
25 Correct 51 ms 3252 KB Output is correct
26 Correct 50 ms 3412 KB Output is correct
27 Correct 49 ms 3444 KB Output is correct
28 Correct 49 ms 3444 KB Output is correct
29 Correct 52 ms 3436 KB Output is correct
30 Correct 48 ms 3432 KB Output is correct
31 Correct 51 ms 3444 KB Output is correct
32 Correct 50 ms 3436 KB Output is correct
33 Correct 52 ms 3412 KB Output is correct
34 Correct 49 ms 3436 KB Output is correct
35 Correct 50 ms 3428 KB Output is correct
36 Correct 47 ms 3432 KB Output is correct
37 Correct 266 ms 6660 KB Output is correct
38 Correct 224 ms 6660 KB Output is correct
39 Correct 419 ms 7996 KB Output is correct
40 Correct 487 ms 8804 KB Output is correct
41 Correct 502 ms 8672 KB Output is correct
42 Correct 396 ms 8188 KB Output is correct
43 Correct 379 ms 8260 KB Output is correct
44 Correct 394 ms 8388 KB Output is correct
45 Correct 393 ms 8444 KB Output is correct
46 Correct 490 ms 8672 KB Output is correct
47 Correct 394 ms 8188 KB Output is correct
48 Correct 407 ms 8328 KB Output is correct
49 Correct 420 ms 8056 KB Output is correct
50 Correct 380 ms 8184 KB Output is correct
51 Correct 379 ms 8056 KB Output is correct
52 Correct 480 ms 9052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 6 ms 1236 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 4 ms 1184 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 4 ms 1236 KB Output is correct
16 Correct 5 ms 1300 KB Output is correct
17 Correct 2 ms 852 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 4 ms 1108 KB Output is correct
20 Correct 5 ms 1236 KB Output is correct
21 Correct 20 ms 2260 KB Output is correct
22 Correct 29 ms 2644 KB Output is correct
23 Correct 12 ms 1912 KB Output is correct
24 Correct 42 ms 3260 KB Output is correct
25 Correct 51 ms 3252 KB Output is correct
26 Correct 50 ms 3412 KB Output is correct
27 Correct 49 ms 3444 KB Output is correct
28 Correct 49 ms 3444 KB Output is correct
29 Correct 52 ms 3436 KB Output is correct
30 Correct 48 ms 3432 KB Output is correct
31 Correct 51 ms 3444 KB Output is correct
32 Correct 50 ms 3436 KB Output is correct
33 Correct 52 ms 3412 KB Output is correct
34 Correct 49 ms 3436 KB Output is correct
35 Correct 50 ms 3428 KB Output is correct
36 Correct 47 ms 3432 KB Output is correct
37 Correct 266 ms 6660 KB Output is correct
38 Correct 224 ms 6660 KB Output is correct
39 Correct 419 ms 7996 KB Output is correct
40 Correct 487 ms 8804 KB Output is correct
41 Correct 502 ms 8672 KB Output is correct
42 Correct 396 ms 8188 KB Output is correct
43 Correct 379 ms 8260 KB Output is correct
44 Correct 394 ms 8388 KB Output is correct
45 Correct 393 ms 8444 KB Output is correct
46 Correct 490 ms 8672 KB Output is correct
47 Correct 394 ms 8188 KB Output is correct
48 Correct 407 ms 8328 KB Output is correct
49 Correct 420 ms 8056 KB Output is correct
50 Correct 380 ms 8184 KB Output is correct
51 Correct 379 ms 8056 KB Output is correct
52 Correct 480 ms 9052 KB Output is correct
53 Correct 653 ms 9932 KB Output is correct
54 Correct 915 ms 11508 KB Output is correct
55 Correct 984 ms 11660 KB Output is correct
56 Correct 686 ms 10124 KB Output is correct
57 Execution timed out 1020 ms 11776 KB Time limit exceeded
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 6 ms 1236 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 5 ms 1236 KB Output is correct
13 Correct 4 ms 1184 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
15 Correct 4 ms 1236 KB Output is correct
16 Correct 5 ms 1300 KB Output is correct
17 Correct 2 ms 852 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 4 ms 1108 KB Output is correct
20 Correct 5 ms 1236 KB Output is correct
21 Correct 20 ms 2260 KB Output is correct
22 Correct 29 ms 2644 KB Output is correct
23 Correct 12 ms 1912 KB Output is correct
24 Correct 42 ms 3260 KB Output is correct
25 Correct 51 ms 3252 KB Output is correct
26 Correct 50 ms 3412 KB Output is correct
27 Correct 49 ms 3444 KB Output is correct
28 Correct 49 ms 3444 KB Output is correct
29 Correct 52 ms 3436 KB Output is correct
30 Correct 48 ms 3432 KB Output is correct
31 Correct 51 ms 3444 KB Output is correct
32 Correct 50 ms 3436 KB Output is correct
33 Correct 52 ms 3412 KB Output is correct
34 Correct 49 ms 3436 KB Output is correct
35 Correct 50 ms 3428 KB Output is correct
36 Correct 47 ms 3432 KB Output is correct
37 Correct 266 ms 6660 KB Output is correct
38 Correct 224 ms 6660 KB Output is correct
39 Correct 419 ms 7996 KB Output is correct
40 Correct 487 ms 8804 KB Output is correct
41 Correct 502 ms 8672 KB Output is correct
42 Correct 396 ms 8188 KB Output is correct
43 Correct 379 ms 8260 KB Output is correct
44 Correct 394 ms 8388 KB Output is correct
45 Correct 393 ms 8444 KB Output is correct
46 Correct 490 ms 8672 KB Output is correct
47 Correct 394 ms 8188 KB Output is correct
48 Correct 407 ms 8328 KB Output is correct
49 Correct 420 ms 8056 KB Output is correct
50 Correct 380 ms 8184 KB Output is correct
51 Correct 379 ms 8056 KB Output is correct
52 Correct 480 ms 9052 KB Output is correct
53 Correct 653 ms 9932 KB Output is correct
54 Correct 915 ms 11508 KB Output is correct
55 Correct 984 ms 11660 KB Output is correct
56 Correct 686 ms 10124 KB Output is correct
57 Execution timed out 1020 ms 11776 KB Time limit exceeded
58 Halted 0 ms 0 KB -