답안 #333662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333662 2020-12-07T11:37:43 Z tengiz05 Bootfall (IZhO17_bootfall) C++17
100 / 100
396 ms 5864 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
const int mod = 1e9+7, N = 505;
int msb(int val){return sizeof(int)*8-__builtin_clzll(val);}
int a[N], n, m, k;
int dp[N*N], can[N*N];
int sum;
void add(int v){
	for(int i=sum;i>=0;i--)dp[i+v] += dp[i];
	sum += v;
}
void del(int v){
	sum -= v;
	for(int i=0;i<=sum;i++)dp[i+v] -= dp[i];
}
void solve(int test_case){
	int i, j;
	dp[0] = 1;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		add(a[i]);
	}
	if(sum%2!=0 || !dp[sum/2]){
		cout << 0 << '\n';
		return;
	}
	
	for(i=0;i<n;i++){
		del(a[i]);
		for(j=1;j<=250000;j++){
			if((sum+j)%2 || !dp[(sum+j)/2])can[j] = 1;
		}add(a[i]);
	}
	vector<int> ans;
	for(i=1;i<=250000;i++)if(!can[i])ans.pb(i);
	cout << ans.size() << '\n';
	for(auto x : ans)cout <<x<< ' ';
	cout << '\n';
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 6 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 6 ms 2292 KB Output is correct
9 Correct 5 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 6 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 6 ms 2292 KB Output is correct
9 Correct 5 ms 2284 KB Output is correct
10 Correct 11 ms 2284 KB Output is correct
11 Correct 11 ms 2284 KB Output is correct
12 Correct 11 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 ms 2284 KB Output is correct
19 Correct 10 ms 2284 KB Output is correct
20 Correct 11 ms 2304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 6 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 6 ms 2292 KB Output is correct
9 Correct 5 ms 2284 KB Output is correct
10 Correct 11 ms 2284 KB Output is correct
11 Correct 11 ms 2284 KB Output is correct
12 Correct 11 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 ms 2284 KB Output is correct
19 Correct 10 ms 2284 KB Output is correct
20 Correct 11 ms 2304 KB Output is correct
21 Correct 21 ms 2412 KB Output is correct
22 Correct 28 ms 2412 KB Output is correct
23 Correct 18 ms 2412 KB Output is correct
24 Correct 32 ms 2412 KB Output is correct
25 Correct 32 ms 2560 KB Output is correct
26 Correct 34 ms 2412 KB Output is correct
27 Correct 33 ms 2412 KB Output is correct
28 Correct 33 ms 2540 KB Output is correct
29 Correct 41 ms 2412 KB Output is correct
30 Correct 32 ms 2284 KB Output is correct
31 Correct 33 ms 2424 KB Output is correct
32 Correct 32 ms 2412 KB Output is correct
33 Correct 41 ms 2412 KB Output is correct
34 Correct 40 ms 2412 KB Output is correct
35 Correct 34 ms 2412 KB Output is correct
36 Correct 32 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 6 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 6 ms 2292 KB Output is correct
9 Correct 5 ms 2284 KB Output is correct
10 Correct 11 ms 2284 KB Output is correct
11 Correct 11 ms 2284 KB Output is correct
12 Correct 11 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 ms 2284 KB Output is correct
19 Correct 10 ms 2284 KB Output is correct
20 Correct 11 ms 2304 KB Output is correct
21 Correct 21 ms 2412 KB Output is correct
22 Correct 28 ms 2412 KB Output is correct
23 Correct 18 ms 2412 KB Output is correct
24 Correct 32 ms 2412 KB Output is correct
25 Correct 32 ms 2560 KB Output is correct
26 Correct 34 ms 2412 KB Output is correct
27 Correct 33 ms 2412 KB Output is correct
28 Correct 33 ms 2540 KB Output is correct
29 Correct 41 ms 2412 KB Output is correct
30 Correct 32 ms 2284 KB Output is correct
31 Correct 33 ms 2424 KB Output is correct
32 Correct 32 ms 2412 KB Output is correct
33 Correct 41 ms 2412 KB Output is correct
34 Correct 40 ms 2412 KB Output is correct
35 Correct 34 ms 2412 KB Output is correct
36 Correct 32 ms 2412 KB Output is correct
37 Correct 69 ms 2668 KB Output is correct
38 Correct 68 ms 2668 KB Output is correct
39 Correct 104 ms 2924 KB Output is correct
40 Correct 97 ms 2924 KB Output is correct
41 Correct 119 ms 2924 KB Output is correct
42 Correct 92 ms 2924 KB Output is correct
43 Correct 102 ms 3184 KB Output is correct
44 Correct 102 ms 3184 KB Output is correct
45 Correct 105 ms 3344 KB Output is correct
46 Correct 95 ms 2540 KB Output is correct
47 Correct 91 ms 2924 KB Output is correct
48 Correct 113 ms 3184 KB Output is correct
49 Correct 106 ms 3052 KB Output is correct
50 Correct 91 ms 2924 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 119 ms 3440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 6 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 6 ms 2292 KB Output is correct
9 Correct 5 ms 2284 KB Output is correct
10 Correct 11 ms 2284 KB Output is correct
11 Correct 11 ms 2284 KB Output is correct
12 Correct 11 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 ms 2284 KB Output is correct
19 Correct 10 ms 2284 KB Output is correct
20 Correct 11 ms 2304 KB Output is correct
21 Correct 21 ms 2412 KB Output is correct
22 Correct 28 ms 2412 KB Output is correct
23 Correct 18 ms 2412 KB Output is correct
24 Correct 32 ms 2412 KB Output is correct
25 Correct 32 ms 2560 KB Output is correct
26 Correct 34 ms 2412 KB Output is correct
27 Correct 33 ms 2412 KB Output is correct
28 Correct 33 ms 2540 KB Output is correct
29 Correct 41 ms 2412 KB Output is correct
30 Correct 32 ms 2284 KB Output is correct
31 Correct 33 ms 2424 KB Output is correct
32 Correct 32 ms 2412 KB Output is correct
33 Correct 41 ms 2412 KB Output is correct
34 Correct 40 ms 2412 KB Output is correct
35 Correct 34 ms 2412 KB Output is correct
36 Correct 32 ms 2412 KB Output is correct
37 Correct 69 ms 2668 KB Output is correct
38 Correct 68 ms 2668 KB Output is correct
39 Correct 104 ms 2924 KB Output is correct
40 Correct 97 ms 2924 KB Output is correct
41 Correct 119 ms 2924 KB Output is correct
42 Correct 92 ms 2924 KB Output is correct
43 Correct 102 ms 3184 KB Output is correct
44 Correct 102 ms 3184 KB Output is correct
45 Correct 105 ms 3344 KB Output is correct
46 Correct 95 ms 2540 KB Output is correct
47 Correct 91 ms 2924 KB Output is correct
48 Correct 113 ms 3184 KB Output is correct
49 Correct 106 ms 3052 KB Output is correct
50 Correct 91 ms 2924 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 119 ms 3440 KB Output is correct
53 Correct 121 ms 3056 KB Output is correct
54 Correct 143 ms 3184 KB Output is correct
55 Correct 186 ms 3948 KB Output is correct
56 Correct 130 ms 3312 KB Output is correct
57 Correct 195 ms 4076 KB Output is correct
58 Correct 147 ms 3312 KB Output is correct
59 Correct 160 ms 3604 KB Output is correct
60 Correct 7 ms 876 KB Output is correct
61 Correct 168 ms 3692 KB Output is correct
62 Correct 157 ms 3820 KB Output is correct
63 Correct 163 ms 3948 KB Output is correct
64 Correct 159 ms 3948 KB Output is correct
65 Correct 127 ms 2796 KB Output is correct
66 Correct 124 ms 2924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 6 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 6 ms 2292 KB Output is correct
9 Correct 5 ms 2284 KB Output is correct
10 Correct 11 ms 2284 KB Output is correct
11 Correct 11 ms 2284 KB Output is correct
12 Correct 11 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 ms 2284 KB Output is correct
19 Correct 10 ms 2284 KB Output is correct
20 Correct 11 ms 2304 KB Output is correct
21 Correct 21 ms 2412 KB Output is correct
22 Correct 28 ms 2412 KB Output is correct
23 Correct 18 ms 2412 KB Output is correct
24 Correct 32 ms 2412 KB Output is correct
25 Correct 32 ms 2560 KB Output is correct
26 Correct 34 ms 2412 KB Output is correct
27 Correct 33 ms 2412 KB Output is correct
28 Correct 33 ms 2540 KB Output is correct
29 Correct 41 ms 2412 KB Output is correct
30 Correct 32 ms 2284 KB Output is correct
31 Correct 33 ms 2424 KB Output is correct
32 Correct 32 ms 2412 KB Output is correct
33 Correct 41 ms 2412 KB Output is correct
34 Correct 40 ms 2412 KB Output is correct
35 Correct 34 ms 2412 KB Output is correct
36 Correct 32 ms 2412 KB Output is correct
37 Correct 69 ms 2668 KB Output is correct
38 Correct 68 ms 2668 KB Output is correct
39 Correct 104 ms 2924 KB Output is correct
40 Correct 97 ms 2924 KB Output is correct
41 Correct 119 ms 2924 KB Output is correct
42 Correct 92 ms 2924 KB Output is correct
43 Correct 102 ms 3184 KB Output is correct
44 Correct 102 ms 3184 KB Output is correct
45 Correct 105 ms 3344 KB Output is correct
46 Correct 95 ms 2540 KB Output is correct
47 Correct 91 ms 2924 KB Output is correct
48 Correct 113 ms 3184 KB Output is correct
49 Correct 106 ms 3052 KB Output is correct
50 Correct 91 ms 2924 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 119 ms 3440 KB Output is correct
53 Correct 121 ms 3056 KB Output is correct
54 Correct 143 ms 3184 KB Output is correct
55 Correct 186 ms 3948 KB Output is correct
56 Correct 130 ms 3312 KB Output is correct
57 Correct 195 ms 4076 KB Output is correct
58 Correct 147 ms 3312 KB Output is correct
59 Correct 160 ms 3604 KB Output is correct
60 Correct 7 ms 876 KB Output is correct
61 Correct 168 ms 3692 KB Output is correct
62 Correct 157 ms 3820 KB Output is correct
63 Correct 163 ms 3948 KB Output is correct
64 Correct 159 ms 3948 KB Output is correct
65 Correct 127 ms 2796 KB Output is correct
66 Correct 124 ms 2924 KB Output is correct
67 Correct 185 ms 3568 KB Output is correct
68 Correct 18 ms 1260 KB Output is correct
69 Correct 365 ms 5736 KB Output is correct
70 Correct 283 ms 4588 KB Output is correct
71 Correct 269 ms 4332 KB Output is correct
72 Correct 267 ms 3536 KB Output is correct
73 Correct 266 ms 3436 KB Output is correct
74 Correct 373 ms 5864 KB Output is correct
75 Correct 329 ms 5096 KB Output is correct
76 Correct 396 ms 5864 KB Output is correct
77 Correct 391 ms 5864 KB Output is correct