답안 #333669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333669 2020-12-07T12:58:00 Z amunduzbaev Bootfall (IZhO17_bootfall) C++14
100 / 100
278 ms 3612 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
const int N = 250000;
int dp[N], used[N];

int main(){
	
	int n;
	cin>>n;
	vector<ll>a(n);
	ll sum = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum += a[i];
	}
	sort(all(a));
	
	dp[0] = 1;
	for(int i=0;i<n;i++){
		for(int j=sum; j>= a[i]; j--){
			dp[j] += dp[j - a[i]];
		}
	}
	if(sum & 1 || !dp[sum/2]){
		cout<<0;
		return 0;
	}
	int cur = sum;
	for(int i=0;i<n;i++){
		for(int j=a[i]; j<= sum; j++){
			dp[j] -= dp[j - a[i]];
		}
		cur -= a[i];
		for(int j = cur/2; j <= sum - a[i]; j++){
			if(dp[j] && j*2 > (sum - a[i])){
				used[j*2 - (sum - a[i])] ++;
			}
		}
		cur += a[i];
		for(int j = sum; j >= a[i]; j--){
			dp[j] += dp[j - a[i]];
		}
	}
	
	vector<int>ans;
	for(int i=1; i<=sum; i++){
		if(used[i] == n) ans.pb(i);
	}
	cout<<ans.size()<<'\n';
	for(auto x:ans) cout<<x<<" ";
	
	return 0;
}
/*
4
1 3 1 5
6
3 5 7 11 9 13
3
2 2 2
4
200 200 200 200
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 3 ms 364 KB Output is correct
34 Correct 4 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 3 ms 364 KB Output is correct
34 Correct 4 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 10 ms 620 KB Output is correct
38 Correct 5 ms 748 KB Output is correct
39 Correct 35 ms 748 KB Output is correct
40 Correct 21 ms 748 KB Output is correct
41 Correct 46 ms 876 KB Output is correct
42 Correct 25 ms 748 KB Output is correct
43 Correct 36 ms 1132 KB Output is correct
44 Correct 35 ms 1260 KB Output is correct
45 Correct 34 ms 1132 KB Output is correct
46 Correct 32 ms 620 KB Output is correct
47 Correct 20 ms 748 KB Output is correct
48 Correct 37 ms 1132 KB Output is correct
49 Correct 40 ms 876 KB Output is correct
50 Correct 20 ms 748 KB Output is correct
51 Correct 5 ms 492 KB Output is correct
52 Correct 45 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 3 ms 364 KB Output is correct
34 Correct 4 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 10 ms 620 KB Output is correct
38 Correct 5 ms 748 KB Output is correct
39 Correct 35 ms 748 KB Output is correct
40 Correct 21 ms 748 KB Output is correct
41 Correct 46 ms 876 KB Output is correct
42 Correct 25 ms 748 KB Output is correct
43 Correct 36 ms 1132 KB Output is correct
44 Correct 35 ms 1260 KB Output is correct
45 Correct 34 ms 1132 KB Output is correct
46 Correct 32 ms 620 KB Output is correct
47 Correct 20 ms 748 KB Output is correct
48 Correct 37 ms 1132 KB Output is correct
49 Correct 40 ms 876 KB Output is correct
50 Correct 20 ms 748 KB Output is correct
51 Correct 5 ms 492 KB Output is correct
52 Correct 45 ms 1260 KB Output is correct
53 Correct 36 ms 1004 KB Output is correct
54 Correct 45 ms 1132 KB Output is correct
55 Correct 90 ms 1768 KB Output is correct
56 Correct 40 ms 1132 KB Output is correct
57 Correct 95 ms 1896 KB Output is correct
58 Correct 50 ms 1260 KB Output is correct
59 Correct 62 ms 1384 KB Output is correct
60 Correct 12 ms 620 KB Output is correct
61 Correct 71 ms 1640 KB Output is correct
62 Correct 72 ms 1660 KB Output is correct
63 Correct 78 ms 1768 KB Output is correct
64 Correct 75 ms 1768 KB Output is correct
65 Correct 40 ms 748 KB Output is correct
66 Correct 39 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 2 ms 364 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 2 ms 364 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 3 ms 364 KB Output is correct
34 Correct 4 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 2 ms 364 KB Output is correct
37 Correct 10 ms 620 KB Output is correct
38 Correct 5 ms 748 KB Output is correct
39 Correct 35 ms 748 KB Output is correct
40 Correct 21 ms 748 KB Output is correct
41 Correct 46 ms 876 KB Output is correct
42 Correct 25 ms 748 KB Output is correct
43 Correct 36 ms 1132 KB Output is correct
44 Correct 35 ms 1260 KB Output is correct
45 Correct 34 ms 1132 KB Output is correct
46 Correct 32 ms 620 KB Output is correct
47 Correct 20 ms 748 KB Output is correct
48 Correct 37 ms 1132 KB Output is correct
49 Correct 40 ms 876 KB Output is correct
50 Correct 20 ms 748 KB Output is correct
51 Correct 5 ms 492 KB Output is correct
52 Correct 45 ms 1260 KB Output is correct
53 Correct 36 ms 1004 KB Output is correct
54 Correct 45 ms 1132 KB Output is correct
55 Correct 90 ms 1768 KB Output is correct
56 Correct 40 ms 1132 KB Output is correct
57 Correct 95 ms 1896 KB Output is correct
58 Correct 50 ms 1260 KB Output is correct
59 Correct 62 ms 1384 KB Output is correct
60 Correct 12 ms 620 KB Output is correct
61 Correct 71 ms 1640 KB Output is correct
62 Correct 72 ms 1660 KB Output is correct
63 Correct 78 ms 1768 KB Output is correct
64 Correct 75 ms 1768 KB Output is correct
65 Correct 40 ms 748 KB Output is correct
66 Correct 39 ms 876 KB Output is correct
67 Correct 73 ms 1512 KB Output is correct
68 Correct 33 ms 876 KB Output is correct
69 Correct 240 ms 3172 KB Output is correct
70 Correct 144 ms 2152 KB Output is correct
71 Correct 145 ms 2024 KB Output is correct
72 Correct 140 ms 1388 KB Output is correct
73 Correct 133 ms 1260 KB Output is correct
74 Correct 256 ms 3300 KB Output is correct
75 Correct 195 ms 2660 KB Output is correct
76 Correct 278 ms 3428 KB Output is correct
77 Correct 270 ms 3612 KB Output is correct