답안 #442126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
442126 2021-07-07T07:44:46 Z Nima_Naderi Bootfall (IZhO17_bootfall) C++14
100 / 100
136 ms 3148 KB
//In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#define md ((s + e) / 2)
#define dm ((s + e) / 2 + 1)
using namespace std;

typedef long long ll;
const ll MXN = 500 + 10;
const ll MXV = 25e4 + 10;
ll n, sum;
ll A[MXN], ANS[MXV];
bitset<MXV> inp;
void Upd(bitset<MXV> &bs, ll w){
	bs |= (bs << w);
}
void solve(ll s, ll e, const bitset<MXV> &old){
	if(s == e){
		sum -= A[s];
		//cout << "expect " << s << " : \n";
		for(int w = (sum + 1) / 2; w <= sum; w ++){
			if(old[w]){
				//cout << w << ' ';
				ANS[w - (sum - w)] ++;
			}
		}
		//cout << '\n';
		sum += A[s];
		return;
	}
	bitset<MXV> nw = old;
	for(int i = dm; i <= e; i ++) Upd(nw, A[i]);
	solve(s, md, nw);
	nw = old;
	for(int i = s; i <= md; i ++) Upd(nw, A[i]);
	solve(dm, e, nw);
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> A[i], sum += A[i];
	inp[0] = 1;
	for(int i = 1; i <= n; i ++) Upd(inp, A[i]);
	if(sum % 2 == 1 || inp[sum / 2] == 0){
		cout << 0 << '\n';
		return 0;
	}
	for(int i = 0; i < MXV; i ++) inp[i] = 0;
	inp[0] = 1;
	solve(1, n, inp);
	ll ans = 0;
	for(int i = 0; i < MXV; i ++) ans += (ANS[i] == n);
	cout << ans << '\n';
	for(int i = 0; i < MXV; i ++){
		if(ANS[i] == n) cout << i << ' ';
	}
	cout << '\n';
	return 0;
}
//! N.N
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 536 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 4 ms 460 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 3 ms 448 KB Output is correct
18 Correct 3 ms 448 KB Output is correct
19 Correct 3 ms 568 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 536 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 4 ms 460 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 3 ms 448 KB Output is correct
18 Correct 3 ms 448 KB Output is correct
19 Correct 3 ms 568 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 6 ms 588 KB Output is correct
22 Correct 7 ms 588 KB Output is correct
23 Correct 5 ms 588 KB Output is correct
24 Correct 9 ms 588 KB Output is correct
25 Correct 9 ms 588 KB Output is correct
26 Correct 10 ms 700 KB Output is correct
27 Correct 10 ms 588 KB Output is correct
28 Correct 10 ms 588 KB Output is correct
29 Correct 10 ms 588 KB Output is correct
30 Correct 9 ms 588 KB Output is correct
31 Correct 10 ms 684 KB Output is correct
32 Correct 9 ms 660 KB Output is correct
33 Correct 9 ms 664 KB Output is correct
34 Correct 9 ms 708 KB Output is correct
35 Correct 10 ms 588 KB Output is correct
36 Correct 9 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 536 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 4 ms 460 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 3 ms 448 KB Output is correct
18 Correct 3 ms 448 KB Output is correct
19 Correct 3 ms 568 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 6 ms 588 KB Output is correct
22 Correct 7 ms 588 KB Output is correct
23 Correct 5 ms 588 KB Output is correct
24 Correct 9 ms 588 KB Output is correct
25 Correct 9 ms 588 KB Output is correct
26 Correct 10 ms 700 KB Output is correct
27 Correct 10 ms 588 KB Output is correct
28 Correct 10 ms 588 KB Output is correct
29 Correct 10 ms 588 KB Output is correct
30 Correct 9 ms 588 KB Output is correct
31 Correct 10 ms 684 KB Output is correct
32 Correct 9 ms 660 KB Output is correct
33 Correct 9 ms 664 KB Output is correct
34 Correct 9 ms 708 KB Output is correct
35 Correct 10 ms 588 KB Output is correct
36 Correct 9 ms 588 KB Output is correct
37 Correct 21 ms 808 KB Output is correct
38 Correct 21 ms 816 KB Output is correct
39 Correct 32 ms 1120 KB Output is correct
40 Correct 31 ms 948 KB Output is correct
41 Correct 35 ms 1100 KB Output is correct
42 Correct 28 ms 888 KB Output is correct
43 Correct 34 ms 1172 KB Output is correct
44 Correct 33 ms 1212 KB Output is correct
45 Correct 34 ms 1220 KB Output is correct
46 Correct 30 ms 928 KB Output is correct
47 Correct 28 ms 968 KB Output is correct
48 Correct 34 ms 1220 KB Output is correct
49 Correct 32 ms 1140 KB Output is correct
50 Correct 29 ms 936 KB Output is correct
51 Correct 3 ms 324 KB Output is correct
52 Correct 39 ms 1352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 536 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 4 ms 460 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 3 ms 448 KB Output is correct
18 Correct 3 ms 448 KB Output is correct
19 Correct 3 ms 568 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 6 ms 588 KB Output is correct
22 Correct 7 ms 588 KB Output is correct
23 Correct 5 ms 588 KB Output is correct
24 Correct 9 ms 588 KB Output is correct
25 Correct 9 ms 588 KB Output is correct
26 Correct 10 ms 700 KB Output is correct
27 Correct 10 ms 588 KB Output is correct
28 Correct 10 ms 588 KB Output is correct
29 Correct 10 ms 588 KB Output is correct
30 Correct 9 ms 588 KB Output is correct
31 Correct 10 ms 684 KB Output is correct
32 Correct 9 ms 660 KB Output is correct
33 Correct 9 ms 664 KB Output is correct
34 Correct 9 ms 708 KB Output is correct
35 Correct 10 ms 588 KB Output is correct
36 Correct 9 ms 588 KB Output is correct
37 Correct 21 ms 808 KB Output is correct
38 Correct 21 ms 816 KB Output is correct
39 Correct 32 ms 1120 KB Output is correct
40 Correct 31 ms 948 KB Output is correct
41 Correct 35 ms 1100 KB Output is correct
42 Correct 28 ms 888 KB Output is correct
43 Correct 34 ms 1172 KB Output is correct
44 Correct 33 ms 1212 KB Output is correct
45 Correct 34 ms 1220 KB Output is correct
46 Correct 30 ms 928 KB Output is correct
47 Correct 28 ms 968 KB Output is correct
48 Correct 34 ms 1220 KB Output is correct
49 Correct 32 ms 1140 KB Output is correct
50 Correct 29 ms 936 KB Output is correct
51 Correct 3 ms 324 KB Output is correct
52 Correct 39 ms 1352 KB Output is correct
53 Correct 38 ms 1032 KB Output is correct
54 Correct 48 ms 1240 KB Output is correct
55 Correct 61 ms 1732 KB Output is correct
56 Correct 41 ms 1232 KB Output is correct
57 Correct 64 ms 1812 KB Output is correct
58 Correct 48 ms 1288 KB Output is correct
59 Correct 53 ms 1476 KB Output is correct
60 Correct 4 ms 332 KB Output is correct
61 Correct 56 ms 1464 KB Output is correct
62 Correct 52 ms 1604 KB Output is correct
63 Correct 54 ms 1860 KB Output is correct
64 Correct 53 ms 1736 KB Output is correct
65 Correct 42 ms 1052 KB Output is correct
66 Correct 39 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 3 ms 536 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 4 ms 460 KB Output is correct
12 Correct 4 ms 472 KB Output is correct
13 Correct 3 ms 460 KB Output is correct
14 Correct 4 ms 460 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 4 ms 460 KB Output is correct
17 Correct 3 ms 448 KB Output is correct
18 Correct 3 ms 448 KB Output is correct
19 Correct 3 ms 568 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 6 ms 588 KB Output is correct
22 Correct 7 ms 588 KB Output is correct
23 Correct 5 ms 588 KB Output is correct
24 Correct 9 ms 588 KB Output is correct
25 Correct 9 ms 588 KB Output is correct
26 Correct 10 ms 700 KB Output is correct
27 Correct 10 ms 588 KB Output is correct
28 Correct 10 ms 588 KB Output is correct
29 Correct 10 ms 588 KB Output is correct
30 Correct 9 ms 588 KB Output is correct
31 Correct 10 ms 684 KB Output is correct
32 Correct 9 ms 660 KB Output is correct
33 Correct 9 ms 664 KB Output is correct
34 Correct 9 ms 708 KB Output is correct
35 Correct 10 ms 588 KB Output is correct
36 Correct 9 ms 588 KB Output is correct
37 Correct 21 ms 808 KB Output is correct
38 Correct 21 ms 816 KB Output is correct
39 Correct 32 ms 1120 KB Output is correct
40 Correct 31 ms 948 KB Output is correct
41 Correct 35 ms 1100 KB Output is correct
42 Correct 28 ms 888 KB Output is correct
43 Correct 34 ms 1172 KB Output is correct
44 Correct 33 ms 1212 KB Output is correct
45 Correct 34 ms 1220 KB Output is correct
46 Correct 30 ms 928 KB Output is correct
47 Correct 28 ms 968 KB Output is correct
48 Correct 34 ms 1220 KB Output is correct
49 Correct 32 ms 1140 KB Output is correct
50 Correct 29 ms 936 KB Output is correct
51 Correct 3 ms 324 KB Output is correct
52 Correct 39 ms 1352 KB Output is correct
53 Correct 38 ms 1032 KB Output is correct
54 Correct 48 ms 1240 KB Output is correct
55 Correct 61 ms 1732 KB Output is correct
56 Correct 41 ms 1232 KB Output is correct
57 Correct 64 ms 1812 KB Output is correct
58 Correct 48 ms 1288 KB Output is correct
59 Correct 53 ms 1476 KB Output is correct
60 Correct 4 ms 332 KB Output is correct
61 Correct 56 ms 1464 KB Output is correct
62 Correct 52 ms 1604 KB Output is correct
63 Correct 54 ms 1860 KB Output is correct
64 Correct 53 ms 1736 KB Output is correct
65 Correct 42 ms 1052 KB Output is correct
66 Correct 39 ms 1092 KB Output is correct
67 Correct 61 ms 1476 KB Output is correct
68 Correct 5 ms 332 KB Output is correct
69 Correct 123 ms 2960 KB Output is correct
70 Correct 92 ms 1988 KB Output is correct
71 Correct 94 ms 1904 KB Output is correct
72 Correct 95 ms 1648 KB Output is correct
73 Correct 88 ms 1612 KB Output is correct
74 Correct 130 ms 3064 KB Output is correct
75 Correct 108 ms 2544 KB Output is correct
76 Correct 136 ms 3140 KB Output is correct
77 Correct 132 ms 3148 KB Output is correct