답안 #438170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438170 2021-06-27T17:28:35 Z lulwpop Bootfall (IZhO17_bootfall) C++14
28 / 100
51 ms 540 KB
#include <bits/stdc++.h>
#define all(X) X.begin(), X.end()
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define endl '\n'
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int maxn = 25001;
const int maxa = 1e6;
const int inf = 2e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const int block = 350;
 
int main () 
{
	ios_base::sync_with_stdio(0); cin.tie();
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int n; cin >> n;
	vector <int> a (n);
	int mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	bitset <maxn> st;
	int sum = 0;
	st[0] = 1;
	for (int i = 0; i < n; i++) {
		st |= (st << a[i]);
		sum += a[i];
	}
	if (sum % 2 == 1 || !st[sum >> 1]) {
		cout << 0;
		return 0;
	}
 	vector <int> used (maxn);
 	for (int i = 0; i < n; i++) {
 		bitset <maxn> dp;
 		dp[0] = 1;
 		int cur_sum = 0;
 		for (int j = 0; j < n; j++) {
 			if (i != j) {
 				dp |= (dp << a[j]);
 				cur_sum += a[j];
 			}
 		} 
 		for (int ins = 1; ins < maxn; ins++) {
 			if ((cur_sum + ins) % 2 == 0 && dp[(cur_sum + ins) >> 1]) {
 				used[ins]++;
 			}
 		}
 	}
 	vector <int> ans;
 	for (int i = 0; i < maxn; i++) {
 		if (used[i] == n) {
 			ans.push_back(i);
 		}
 	}
 	cout << sz(ans) << endl;
 	for (auto i : ans) {
 		cout << i << " ";
 	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 4 ms 320 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 424 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 4 ms 320 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 424 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 7 ms 332 KB Output is correct
22 Correct 11 ms 412 KB Output is correct
23 Correct 4 ms 332 KB Output is correct
24 Correct 11 ms 424 KB Output is correct
25 Correct 11 ms 420 KB Output is correct
26 Correct 13 ms 420 KB Output is correct
27 Correct 13 ms 332 KB Output is correct
28 Correct 13 ms 372 KB Output is correct
29 Correct 13 ms 320 KB Output is correct
30 Correct 12 ms 332 KB Output is correct
31 Correct 15 ms 460 KB Output is correct
32 Correct 12 ms 424 KB Output is correct
33 Correct 12 ms 332 KB Output is correct
34 Correct 12 ms 420 KB Output is correct
35 Correct 12 ms 412 KB Output is correct
36 Correct 12 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 4 ms 320 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 424 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 7 ms 332 KB Output is correct
22 Correct 11 ms 412 KB Output is correct
23 Correct 4 ms 332 KB Output is correct
24 Correct 11 ms 424 KB Output is correct
25 Correct 11 ms 420 KB Output is correct
26 Correct 13 ms 420 KB Output is correct
27 Correct 13 ms 332 KB Output is correct
28 Correct 13 ms 372 KB Output is correct
29 Correct 13 ms 320 KB Output is correct
30 Correct 12 ms 332 KB Output is correct
31 Correct 15 ms 460 KB Output is correct
32 Correct 12 ms 424 KB Output is correct
33 Correct 12 ms 332 KB Output is correct
34 Correct 12 ms 420 KB Output is correct
35 Correct 12 ms 412 KB Output is correct
36 Correct 12 ms 460 KB Output is correct
37 Correct 51 ms 540 KB Output is correct
38 Correct 41 ms 536 KB Output is correct
39 Incorrect 1 ms 204 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 4 ms 320 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 424 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 7 ms 332 KB Output is correct
22 Correct 11 ms 412 KB Output is correct
23 Correct 4 ms 332 KB Output is correct
24 Correct 11 ms 424 KB Output is correct
25 Correct 11 ms 420 KB Output is correct
26 Correct 13 ms 420 KB Output is correct
27 Correct 13 ms 332 KB Output is correct
28 Correct 13 ms 372 KB Output is correct
29 Correct 13 ms 320 KB Output is correct
30 Correct 12 ms 332 KB Output is correct
31 Correct 15 ms 460 KB Output is correct
32 Correct 12 ms 424 KB Output is correct
33 Correct 12 ms 332 KB Output is correct
34 Correct 12 ms 420 KB Output is correct
35 Correct 12 ms 412 KB Output is correct
36 Correct 12 ms 460 KB Output is correct
37 Correct 51 ms 540 KB Output is correct
38 Correct 41 ms 536 KB Output is correct
39 Incorrect 1 ms 204 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 4 ms 320 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 3 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 2 ms 424 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 7 ms 332 KB Output is correct
22 Correct 11 ms 412 KB Output is correct
23 Correct 4 ms 332 KB Output is correct
24 Correct 11 ms 424 KB Output is correct
25 Correct 11 ms 420 KB Output is correct
26 Correct 13 ms 420 KB Output is correct
27 Correct 13 ms 332 KB Output is correct
28 Correct 13 ms 372 KB Output is correct
29 Correct 13 ms 320 KB Output is correct
30 Correct 12 ms 332 KB Output is correct
31 Correct 15 ms 460 KB Output is correct
32 Correct 12 ms 424 KB Output is correct
33 Correct 12 ms 332 KB Output is correct
34 Correct 12 ms 420 KB Output is correct
35 Correct 12 ms 412 KB Output is correct
36 Correct 12 ms 460 KB Output is correct
37 Correct 51 ms 540 KB Output is correct
38 Correct 41 ms 536 KB Output is correct
39 Incorrect 1 ms 204 KB Output isn't correct
40 Halted 0 ms 0 KB -