답안 #499364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499364 2021-12-28T05:21:31 Z beksultan04 Bootfall (IZhO17_bootfall) C++14
100 / 100
253 ms 5672 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int,int>
#define ret return
#define fr first
#define sc second
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define nosol puts("-1");
#define pb push_back
#define endi puts("");
#define ordered_set tree <int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 2e6+12,INF = 1e18+7;
int q[N],dp[N],sum;

void add(int x){
	for (int i = sum;i>=0;--i)
		dp[i+x] += dp[i];
}

void del(int x){
	for (int i = 0;i <= sum;++i)
		dp[i+x] -= dp[i];
}

int cnt[N];

main(){
	int n,i,j;
	cin>>n;
	dp[0]=1;
	for (i=1;i<=n;++i){
		cin>>q[i];
		add(q[i]);
		sum += q[i];
	}
	if (sum&1 || dp[sum/2] == 0){
		cout <<0;
		ret 0;
	}
	
	for (i=1;i<=n;++i){
		del(q[i]);
		sum -= q[i];
		for (j = sum/2; j <= sum;++j){
			if (dp[j]  && j*2 > sum){
				cnt[j*2-sum]++;
			}
		}
		sum += q[i];
		add(q[i]);
	}
	vector <int> ans;
	for (i=1;i<=sum;++i)
		if (cnt[i] == n)
			ans.pb(i);
		
	
	cout <<ans.size()<<"\n";
	for (auto x:ans)cout <<x<<" ";
	
}








Compilation message

bootfall.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 3 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 3 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 9 ms 844 KB Output is correct
38 Correct 9 ms 884 KB Output is correct
39 Correct 31 ms 1228 KB Output is correct
40 Correct 19 ms 1072 KB Output is correct
41 Correct 41 ms 1408 KB Output is correct
42 Correct 17 ms 1124 KB Output is correct
43 Correct 33 ms 1536 KB Output is correct
44 Correct 30 ms 1584 KB Output is correct
45 Correct 32 ms 1568 KB Output is correct
46 Correct 18 ms 812 KB Output is correct
47 Correct 18 ms 1100 KB Output is correct
48 Correct 32 ms 1584 KB Output is correct
49 Correct 33 ms 1388 KB Output is correct
50 Correct 18 ms 1096 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 40 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 3 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 9 ms 844 KB Output is correct
38 Correct 9 ms 884 KB Output is correct
39 Correct 31 ms 1228 KB Output is correct
40 Correct 19 ms 1072 KB Output is correct
41 Correct 41 ms 1408 KB Output is correct
42 Correct 17 ms 1124 KB Output is correct
43 Correct 33 ms 1536 KB Output is correct
44 Correct 30 ms 1584 KB Output is correct
45 Correct 32 ms 1568 KB Output is correct
46 Correct 18 ms 812 KB Output is correct
47 Correct 18 ms 1100 KB Output is correct
48 Correct 32 ms 1584 KB Output is correct
49 Correct 33 ms 1388 KB Output is correct
50 Correct 18 ms 1096 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 40 ms 1912 KB Output is correct
53 Correct 28 ms 1480 KB Output is correct
54 Correct 39 ms 1680 KB Output is correct
55 Correct 95 ms 2808 KB Output is correct
56 Correct 40 ms 1684 KB Output is correct
57 Correct 102 ms 2884 KB Output is correct
58 Correct 43 ms 1764 KB Output is correct
59 Correct 56 ms 2064 KB Output is correct
60 Correct 7 ms 716 KB Output is correct
61 Correct 60 ms 2288 KB Output is correct
62 Correct 62 ms 2552 KB Output is correct
63 Correct 71 ms 2680 KB Output is correct
64 Correct 79 ms 2660 KB Output is correct
65 Correct 34 ms 1076 KB Output is correct
66 Correct 34 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 3 ms 460 KB Output is correct
26 Correct 4 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 3 ms 460 KB Output is correct
34 Correct 3 ms 460 KB Output is correct
35 Correct 3 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 9 ms 844 KB Output is correct
38 Correct 9 ms 884 KB Output is correct
39 Correct 31 ms 1228 KB Output is correct
40 Correct 19 ms 1072 KB Output is correct
41 Correct 41 ms 1408 KB Output is correct
42 Correct 17 ms 1124 KB Output is correct
43 Correct 33 ms 1536 KB Output is correct
44 Correct 30 ms 1584 KB Output is correct
45 Correct 32 ms 1568 KB Output is correct
46 Correct 18 ms 812 KB Output is correct
47 Correct 18 ms 1100 KB Output is correct
48 Correct 32 ms 1584 KB Output is correct
49 Correct 33 ms 1388 KB Output is correct
50 Correct 18 ms 1096 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 40 ms 1912 KB Output is correct
53 Correct 28 ms 1480 KB Output is correct
54 Correct 39 ms 1680 KB Output is correct
55 Correct 95 ms 2808 KB Output is correct
56 Correct 40 ms 1684 KB Output is correct
57 Correct 102 ms 2884 KB Output is correct
58 Correct 43 ms 1764 KB Output is correct
59 Correct 56 ms 2064 KB Output is correct
60 Correct 7 ms 716 KB Output is correct
61 Correct 60 ms 2288 KB Output is correct
62 Correct 62 ms 2552 KB Output is correct
63 Correct 71 ms 2680 KB Output is correct
64 Correct 79 ms 2660 KB Output is correct
65 Correct 34 ms 1076 KB Output is correct
66 Correct 34 ms 1260 KB Output is correct
67 Correct 63 ms 2364 KB Output is correct
68 Correct 21 ms 1272 KB Output is correct
69 Correct 206 ms 5160 KB Output is correct
70 Correct 136 ms 3320 KB Output is correct
71 Correct 127 ms 3132 KB Output is correct
72 Correct 143 ms 2260 KB Output is correct
73 Correct 122 ms 2256 KB Output is correct
74 Correct 229 ms 5464 KB Output is correct
75 Correct 185 ms 4316 KB Output is correct
76 Correct 249 ms 5652 KB Output is correct
77 Correct 253 ms 5672 KB Output is correct