답안 #501581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
501581 2022-01-04T06:17:58 Z Aktan Bootfall (IZhO17_bootfall) C++17
100 / 100
229 ms 5656 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define ft first
#define sc second
using namespace std;
const int mod=1e9+7,INF=1e17;
int sum,dp[500005],res[500005],a[505];
void fun(int x){
	for(int i=sum;i>=0;i--){
		dp[i+x]+=dp[i];
	}
}
void fun2(int x){
	for(int i=0;i<=sum;i++){
		dp[i+x]-=dp[i];
	}
}
main(){
    int n;
    cin>> n;
    dp[0]=1;
    for(int i=1;i<=n;i++){
    	cin >> a[i];
    	fun(a[i]);
    	sum+=a[i];
	}
	if(sum%2!=0 || dp[sum/2]==0){
		cout << 0;
		return 0;
	}
	for(int i=1;i<=n;i++){
		fun2(a[i]);
		sum-=a[i];
		for(int j=sum/2;j<=sum;j++){
			if(dp[j]!=0 && j*2>sum){
				res[j*2-sum]++;
			}
		}
		sum+=a[i];
		fun(a[i]);
	}
	vector<int> ans;
	for(int i=1;i<=sum;i++){
		if(res[i]==n){
			ans.push_back(i);
		}
	}
	cout << ans.size() << endl;
	for(auto x : ans){
		cout << x << " ";
	}
}

Compilation message

bootfall.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 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 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 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 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 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 1 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 204 KB Output is correct
5 Correct 1 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 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 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 1 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 3 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 332 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 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 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 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 1 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 3 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 332 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 9 ms 872 KB Output is correct
38 Correct 9 ms 844 KB Output is correct
39 Correct 27 ms 1228 KB Output is correct
40 Correct 24 ms 1100 KB Output is correct
41 Correct 32 ms 1420 KB Output is correct
42 Correct 15 ms 1040 KB Output is correct
43 Correct 31 ms 1548 KB Output is correct
44 Correct 28 ms 1696 KB Output is correct
45 Correct 28 ms 1608 KB Output is correct
46 Correct 16 ms 808 KB Output is correct
47 Correct 16 ms 1100 KB Output is correct
48 Correct 30 ms 1652 KB Output is correct
49 Correct 28 ms 1404 KB Output is correct
50 Correct 17 ms 1076 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 36 ms 1896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 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 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 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 1 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 3 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 332 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 9 ms 872 KB Output is correct
38 Correct 9 ms 844 KB Output is correct
39 Correct 27 ms 1228 KB Output is correct
40 Correct 24 ms 1100 KB Output is correct
41 Correct 32 ms 1420 KB Output is correct
42 Correct 15 ms 1040 KB Output is correct
43 Correct 31 ms 1548 KB Output is correct
44 Correct 28 ms 1696 KB Output is correct
45 Correct 28 ms 1608 KB Output is correct
46 Correct 16 ms 808 KB Output is correct
47 Correct 16 ms 1100 KB Output is correct
48 Correct 30 ms 1652 KB Output is correct
49 Correct 28 ms 1404 KB Output is correct
50 Correct 17 ms 1076 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 36 ms 1896 KB Output is correct
53 Correct 31 ms 1392 KB Output is correct
54 Correct 36 ms 1692 KB Output is correct
55 Correct 74 ms 2788 KB Output is correct
56 Correct 34 ms 1580 KB Output is correct
57 Correct 76 ms 2884 KB Output is correct
58 Correct 40 ms 1768 KB Output is correct
59 Correct 54 ms 2124 KB Output is correct
60 Correct 6 ms 716 KB Output is correct
61 Correct 60 ms 2280 KB Output is correct
62 Correct 60 ms 2492 KB Output is correct
63 Correct 68 ms 2688 KB Output is correct
64 Correct 60 ms 2656 KB Output is correct
65 Correct 28 ms 1064 KB Output is correct
66 Correct 28 ms 1220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 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 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 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 1 ms 332 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 3 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 332 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 2 ms 460 KB Output is correct
35 Correct 2 ms 460 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 9 ms 872 KB Output is correct
38 Correct 9 ms 844 KB Output is correct
39 Correct 27 ms 1228 KB Output is correct
40 Correct 24 ms 1100 KB Output is correct
41 Correct 32 ms 1420 KB Output is correct
42 Correct 15 ms 1040 KB Output is correct
43 Correct 31 ms 1548 KB Output is correct
44 Correct 28 ms 1696 KB Output is correct
45 Correct 28 ms 1608 KB Output is correct
46 Correct 16 ms 808 KB Output is correct
47 Correct 16 ms 1100 KB Output is correct
48 Correct 30 ms 1652 KB Output is correct
49 Correct 28 ms 1404 KB Output is correct
50 Correct 17 ms 1076 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 36 ms 1896 KB Output is correct
53 Correct 31 ms 1392 KB Output is correct
54 Correct 36 ms 1692 KB Output is correct
55 Correct 74 ms 2788 KB Output is correct
56 Correct 34 ms 1580 KB Output is correct
57 Correct 76 ms 2884 KB Output is correct
58 Correct 40 ms 1768 KB Output is correct
59 Correct 54 ms 2124 KB Output is correct
60 Correct 6 ms 716 KB Output is correct
61 Correct 60 ms 2280 KB Output is correct
62 Correct 60 ms 2492 KB Output is correct
63 Correct 68 ms 2688 KB Output is correct
64 Correct 60 ms 2656 KB Output is correct
65 Correct 28 ms 1064 KB Output is correct
66 Correct 28 ms 1220 KB Output is correct
67 Correct 60 ms 2192 KB Output is correct
68 Correct 15 ms 1276 KB Output is correct
69 Correct 199 ms 5088 KB Output is correct
70 Correct 118 ms 3260 KB Output is correct
71 Correct 124 ms 3132 KB Output is correct
72 Correct 106 ms 2260 KB Output is correct
73 Correct 108 ms 2256 KB Output is correct
74 Correct 206 ms 5444 KB Output is correct
75 Correct 159 ms 4288 KB Output is correct
76 Correct 229 ms 5620 KB Output is correct
77 Correct 217 ms 5656 KB Output is correct