Submission #684549

# Submission time Handle Problem Language Result Execution time Memory
684549 2023-01-21T17:14:04 Z OrazB Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 856 KB
#include <bits/stdc++.h>
#define N 400005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
using namespace std;

int cnt[N], a[N], dp[N];

int main ()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}
	dp[0]=1;
	for (int i = 1; i <= n; i++){
		for (int j = sum; j >= 0; j--){
			if (dp[j]) dp[j+a[i]]=1;
		}
	}
	if (!dp[sum/2] or sum%2) return cout << 0, 0;
	for (int i = 1; i <= n; i++){
		set<int> s;
		for (int j = 0; j <= sum; j++){
			dp[j]=0;
		}
		dp[0]=1;
		for (int j = 1; j <= n; j++){
			if (i == j) continue;
			for (int k = sum; k >= 0; k--){
				if (dp[k]) dp[k+a[j]]=1;
			}
		}
		int sm = sum-a[i];
		for (int j = 1; j < sum; j++){
			if (dp[j]) s.insert(abs(2*j-sm));
		}	
		for (auto j : s){
			cnt[j]++;
		}
	}
	vector<int> vec;
	for (int i = 0; i < 3e5; i++){
		if (cnt[i] == n) vec.pb(i);
	}
	cout << vec.size() << '\n';
	for (auto i : vec){
		cout << i << " ";
	}
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 2 ms 412 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 2 ms 412 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 40 ms 444 KB Output is correct
22 Correct 53 ms 428 KB Output is correct
23 Correct 19 ms 340 KB Output is correct
24 Correct 108 ms 472 KB Output is correct
25 Correct 154 ms 560 KB Output is correct
26 Correct 181 ms 588 KB Output is correct
27 Correct 119 ms 488 KB Output is correct
28 Correct 120 ms 488 KB Output is correct
29 Correct 133 ms 468 KB Output is correct
30 Correct 125 ms 492 KB Output is correct
31 Correct 181 ms 568 KB Output is correct
32 Correct 117 ms 488 KB Output is correct
33 Correct 77 ms 412 KB Output is correct
34 Correct 78 ms 408 KB Output is correct
35 Correct 126 ms 500 KB Output is correct
36 Correct 117 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 2 ms 412 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 40 ms 444 KB Output is correct
22 Correct 53 ms 428 KB Output is correct
23 Correct 19 ms 340 KB Output is correct
24 Correct 108 ms 472 KB Output is correct
25 Correct 154 ms 560 KB Output is correct
26 Correct 181 ms 588 KB Output is correct
27 Correct 119 ms 488 KB Output is correct
28 Correct 120 ms 488 KB Output is correct
29 Correct 133 ms 468 KB Output is correct
30 Correct 125 ms 492 KB Output is correct
31 Correct 181 ms 568 KB Output is correct
32 Correct 117 ms 488 KB Output is correct
33 Correct 77 ms 412 KB Output is correct
34 Correct 78 ms 408 KB Output is correct
35 Correct 126 ms 500 KB Output is correct
36 Correct 117 ms 480 KB Output is correct
37 Execution timed out 1087 ms 856 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 2 ms 412 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 40 ms 444 KB Output is correct
22 Correct 53 ms 428 KB Output is correct
23 Correct 19 ms 340 KB Output is correct
24 Correct 108 ms 472 KB Output is correct
25 Correct 154 ms 560 KB Output is correct
26 Correct 181 ms 588 KB Output is correct
27 Correct 119 ms 488 KB Output is correct
28 Correct 120 ms 488 KB Output is correct
29 Correct 133 ms 468 KB Output is correct
30 Correct 125 ms 492 KB Output is correct
31 Correct 181 ms 568 KB Output is correct
32 Correct 117 ms 488 KB Output is correct
33 Correct 77 ms 412 KB Output is correct
34 Correct 78 ms 408 KB Output is correct
35 Correct 126 ms 500 KB Output is correct
36 Correct 117 ms 480 KB Output is correct
37 Execution timed out 1087 ms 856 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 328 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 2 ms 412 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 40 ms 444 KB Output is correct
22 Correct 53 ms 428 KB Output is correct
23 Correct 19 ms 340 KB Output is correct
24 Correct 108 ms 472 KB Output is correct
25 Correct 154 ms 560 KB Output is correct
26 Correct 181 ms 588 KB Output is correct
27 Correct 119 ms 488 KB Output is correct
28 Correct 120 ms 488 KB Output is correct
29 Correct 133 ms 468 KB Output is correct
30 Correct 125 ms 492 KB Output is correct
31 Correct 181 ms 568 KB Output is correct
32 Correct 117 ms 488 KB Output is correct
33 Correct 77 ms 412 KB Output is correct
34 Correct 78 ms 408 KB Output is correct
35 Correct 126 ms 500 KB Output is correct
36 Correct 117 ms 480 KB Output is correct
37 Execution timed out 1087 ms 856 KB Time limit exceeded
38 Halted 0 ms 0 KB -