Submission #696986

# Submission time Handle Problem Language Result Execution time Memory
696986 2023-02-07T20:28:52 Z allllekssssa Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 16852 KB
#include<bits/stdc++.h>

using namespace std;

const int maxN = 510;
const int bsSize = 250010;
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 596 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1108 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1108 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 10 ms 2284 KB Output is correct
11 Correct 10 ms 2284 KB Output is correct
12 Correct 10 ms 2260 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 2160 KB Output is correct
15 Correct 9 ms 2156 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
17 Correct 4 ms 1492 KB Output is correct
18 Correct 7 ms 1896 KB Output is correct
19 Correct 8 ms 2004 KB Output is correct
20 Correct 11 ms 2280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1108 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 10 ms 2284 KB Output is correct
11 Correct 10 ms 2284 KB Output is correct
12 Correct 10 ms 2260 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 2160 KB Output is correct
15 Correct 9 ms 2156 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
17 Correct 4 ms 1492 KB Output is correct
18 Correct 7 ms 1896 KB Output is correct
19 Correct 8 ms 2004 KB Output is correct
20 Correct 11 ms 2280 KB Output is correct
21 Correct 44 ms 4332 KB Output is correct
22 Correct 58 ms 4960 KB Output is correct
23 Correct 26 ms 3412 KB Output is correct
24 Correct 102 ms 6184 KB Output is correct
25 Correct 97 ms 6164 KB Output is correct
26 Correct 112 ms 6604 KB Output is correct
27 Correct 118 ms 6484 KB Output is correct
28 Correct 108 ms 6548 KB Output is correct
29 Correct 113 ms 6556 KB Output is correct
30 Correct 108 ms 6484 KB Output is correct
31 Correct 119 ms 6544 KB Output is correct
32 Correct 112 ms 6544 KB Output is correct
33 Correct 109 ms 6544 KB Output is correct
34 Correct 117 ms 6540 KB Output is correct
35 Correct 113 ms 6548 KB Output is correct
36 Correct 114 ms 6544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1108 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 10 ms 2284 KB Output is correct
11 Correct 10 ms 2284 KB Output is correct
12 Correct 10 ms 2260 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 2160 KB Output is correct
15 Correct 9 ms 2156 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
17 Correct 4 ms 1492 KB Output is correct
18 Correct 7 ms 1896 KB Output is correct
19 Correct 8 ms 2004 KB Output is correct
20 Correct 11 ms 2280 KB Output is correct
21 Correct 44 ms 4332 KB Output is correct
22 Correct 58 ms 4960 KB Output is correct
23 Correct 26 ms 3412 KB Output is correct
24 Correct 102 ms 6184 KB Output is correct
25 Correct 97 ms 6164 KB Output is correct
26 Correct 112 ms 6604 KB Output is correct
27 Correct 118 ms 6484 KB Output is correct
28 Correct 108 ms 6548 KB Output is correct
29 Correct 113 ms 6556 KB Output is correct
30 Correct 108 ms 6484 KB Output is correct
31 Correct 119 ms 6544 KB Output is correct
32 Correct 112 ms 6544 KB Output is correct
33 Correct 109 ms 6544 KB Output is correct
34 Correct 117 ms 6540 KB Output is correct
35 Correct 113 ms 6548 KB Output is correct
36 Correct 114 ms 6544 KB Output is correct
37 Correct 608 ms 12900 KB Output is correct
38 Correct 602 ms 12784 KB Output is correct
39 Correct 969 ms 15596 KB Output is correct
40 Execution timed out 1098 ms 16852 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1108 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 10 ms 2284 KB Output is correct
11 Correct 10 ms 2284 KB Output is correct
12 Correct 10 ms 2260 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 2160 KB Output is correct
15 Correct 9 ms 2156 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
17 Correct 4 ms 1492 KB Output is correct
18 Correct 7 ms 1896 KB Output is correct
19 Correct 8 ms 2004 KB Output is correct
20 Correct 11 ms 2280 KB Output is correct
21 Correct 44 ms 4332 KB Output is correct
22 Correct 58 ms 4960 KB Output is correct
23 Correct 26 ms 3412 KB Output is correct
24 Correct 102 ms 6184 KB Output is correct
25 Correct 97 ms 6164 KB Output is correct
26 Correct 112 ms 6604 KB Output is correct
27 Correct 118 ms 6484 KB Output is correct
28 Correct 108 ms 6548 KB Output is correct
29 Correct 113 ms 6556 KB Output is correct
30 Correct 108 ms 6484 KB Output is correct
31 Correct 119 ms 6544 KB Output is correct
32 Correct 112 ms 6544 KB Output is correct
33 Correct 109 ms 6544 KB Output is correct
34 Correct 117 ms 6540 KB Output is correct
35 Correct 113 ms 6548 KB Output is correct
36 Correct 114 ms 6544 KB Output is correct
37 Correct 608 ms 12900 KB Output is correct
38 Correct 602 ms 12784 KB Output is correct
39 Correct 969 ms 15596 KB Output is correct
40 Execution timed out 1098 ms 16852 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 2 ms 1108 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 10 ms 2284 KB Output is correct
11 Correct 10 ms 2284 KB Output is correct
12 Correct 10 ms 2260 KB Output is correct
13 Correct 8 ms 2004 KB Output is correct
14 Correct 9 ms 2160 KB Output is correct
15 Correct 9 ms 2156 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
17 Correct 4 ms 1492 KB Output is correct
18 Correct 7 ms 1896 KB Output is correct
19 Correct 8 ms 2004 KB Output is correct
20 Correct 11 ms 2280 KB Output is correct
21 Correct 44 ms 4332 KB Output is correct
22 Correct 58 ms 4960 KB Output is correct
23 Correct 26 ms 3412 KB Output is correct
24 Correct 102 ms 6184 KB Output is correct
25 Correct 97 ms 6164 KB Output is correct
26 Correct 112 ms 6604 KB Output is correct
27 Correct 118 ms 6484 KB Output is correct
28 Correct 108 ms 6548 KB Output is correct
29 Correct 113 ms 6556 KB Output is correct
30 Correct 108 ms 6484 KB Output is correct
31 Correct 119 ms 6544 KB Output is correct
32 Correct 112 ms 6544 KB Output is correct
33 Correct 109 ms 6544 KB Output is correct
34 Correct 117 ms 6540 KB Output is correct
35 Correct 113 ms 6548 KB Output is correct
36 Correct 114 ms 6544 KB Output is correct
37 Correct 608 ms 12900 KB Output is correct
38 Correct 602 ms 12784 KB Output is correct
39 Correct 969 ms 15596 KB Output is correct
40 Execution timed out 1098 ms 16852 KB Time limit exceeded
41 Halted 0 ms 0 KB -