Submission #501221

# Submission time Handle Problem Language Result Execution time Memory
501221 2022-01-02T16:16:57 Z luka1234 Bootfall (IZhO17_bootfall) C++14
100 / 100
616 ms 4444 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int dp[250001];
int d[250001];
int six[250001];
int main(){
	int n;
	cin>>n;
	int a[n+1];
	int sum=0;
	for(int k=1;k<=n;k++){
		cin>>a[k];
		sum+=a[k];
	}
	if(sum%2==1){
		cout<<0;
		return 0;
	}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=250000;j>=0;j--){
			if(j>=a[i])
			   dp[j]+=dp[j-a[i]];
		}
	}
	if(dp[sum/2]==0){
		cout<<0;
		return 0;
	}
	vector<int> ans;
	for(int i=1;i<=n;i++){
		for(int j=0;j<a[i];j++)
		    d[j]=dp[j];
		for(int j=a[i];j<=250000;j++){
			d[j]=dp[j]-d[j-a[i]];
		}
		for(int j=1;j<=250000;j++){
			if(d[j]==0)
			   continue;
			int x=2*j+a[i]-sum;
			if(x>0){
				six[x]++;
				if(six[x]==n)
				   ans.push_back(x);
			}
		}
	}
	sort(ans.begin(),ans.end());
	cout<<ans.size()<<"\n";
	for(int k=0;k<ans.size();k++)
	    cout<<ans[k]<<' ';
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:53:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for(int k=0;k<ans.size();k++)
      |              ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2220 KB Output is correct
2 Correct 5 ms 2228 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 8 ms 2252 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 7 ms 2272 KB Output is correct
9 Correct 6 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2220 KB Output is correct
2 Correct 5 ms 2228 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 8 ms 2252 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 7 ms 2272 KB Output is correct
9 Correct 6 ms 2264 KB Output is correct
10 Correct 22 ms 2264 KB Output is correct
11 Correct 20 ms 2252 KB Output is correct
12 Correct 24 ms 2172 KB Output is correct
13 Correct 18 ms 2220 KB Output is correct
14 Correct 21 ms 2264 KB Output is correct
15 Correct 23 ms 2224 KB Output is correct
16 Correct 21 ms 2248 KB Output is correct
17 Correct 12 ms 2260 KB Output is correct
18 Correct 19 ms 2260 KB Output is correct
19 Correct 16 ms 2168 KB Output is correct
20 Correct 20 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2220 KB Output is correct
2 Correct 5 ms 2228 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 8 ms 2252 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 7 ms 2272 KB Output is correct
9 Correct 6 ms 2264 KB Output is correct
10 Correct 22 ms 2264 KB Output is correct
11 Correct 20 ms 2252 KB Output is correct
12 Correct 24 ms 2172 KB Output is correct
13 Correct 18 ms 2220 KB Output is correct
14 Correct 21 ms 2264 KB Output is correct
15 Correct 23 ms 2224 KB Output is correct
16 Correct 21 ms 2248 KB Output is correct
17 Correct 12 ms 2260 KB Output is correct
18 Correct 19 ms 2260 KB Output is correct
19 Correct 16 ms 2168 KB Output is correct
20 Correct 20 ms 2260 KB Output is correct
21 Correct 43 ms 2252 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 37 ms 2248 KB Output is correct
24 Correct 50 ms 2264 KB Output is correct
25 Correct 56 ms 2268 KB Output is correct
26 Correct 56 ms 2280 KB Output is correct
27 Correct 60 ms 2276 KB Output is correct
28 Correct 52 ms 2308 KB Output is correct
29 Correct 55 ms 2172 KB Output is correct
30 Correct 56 ms 2180 KB Output is correct
31 Correct 57 ms 2272 KB Output is correct
32 Correct 53 ms 2252 KB Output is correct
33 Correct 52 ms 2284 KB Output is correct
34 Correct 65 ms 2156 KB Output is correct
35 Correct 53 ms 2168 KB Output is correct
36 Correct 59 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2220 KB Output is correct
2 Correct 5 ms 2228 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 8 ms 2252 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 7 ms 2272 KB Output is correct
9 Correct 6 ms 2264 KB Output is correct
10 Correct 22 ms 2264 KB Output is correct
11 Correct 20 ms 2252 KB Output is correct
12 Correct 24 ms 2172 KB Output is correct
13 Correct 18 ms 2220 KB Output is correct
14 Correct 21 ms 2264 KB Output is correct
15 Correct 23 ms 2224 KB Output is correct
16 Correct 21 ms 2248 KB Output is correct
17 Correct 12 ms 2260 KB Output is correct
18 Correct 19 ms 2260 KB Output is correct
19 Correct 16 ms 2168 KB Output is correct
20 Correct 20 ms 2260 KB Output is correct
21 Correct 43 ms 2252 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 37 ms 2248 KB Output is correct
24 Correct 50 ms 2264 KB Output is correct
25 Correct 56 ms 2268 KB Output is correct
26 Correct 56 ms 2280 KB Output is correct
27 Correct 60 ms 2276 KB Output is correct
28 Correct 52 ms 2308 KB Output is correct
29 Correct 55 ms 2172 KB Output is correct
30 Correct 56 ms 2180 KB Output is correct
31 Correct 57 ms 2272 KB Output is correct
32 Correct 53 ms 2252 KB Output is correct
33 Correct 52 ms 2284 KB Output is correct
34 Correct 65 ms 2156 KB Output is correct
35 Correct 53 ms 2168 KB Output is correct
36 Correct 59 ms 2284 KB Output is correct
37 Correct 114 ms 2444 KB Output is correct
38 Correct 128 ms 2444 KB Output is correct
39 Correct 139 ms 2484 KB Output is correct
40 Correct 206 ms 2552 KB Output is correct
41 Correct 143 ms 2428 KB Output is correct
42 Correct 171 ms 2540 KB Output is correct
43 Correct 206 ms 2844 KB Output is correct
44 Correct 177 ms 2840 KB Output is correct
45 Correct 178 ms 2796 KB Output is correct
46 Correct 178 ms 2288 KB Output is correct
47 Correct 166 ms 2504 KB Output is correct
48 Correct 170 ms 2724 KB Output is correct
49 Correct 146 ms 2552 KB Output is correct
50 Correct 195 ms 2500 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 209 ms 2892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2220 KB Output is correct
2 Correct 5 ms 2228 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 8 ms 2252 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 7 ms 2272 KB Output is correct
9 Correct 6 ms 2264 KB Output is correct
10 Correct 22 ms 2264 KB Output is correct
11 Correct 20 ms 2252 KB Output is correct
12 Correct 24 ms 2172 KB Output is correct
13 Correct 18 ms 2220 KB Output is correct
14 Correct 21 ms 2264 KB Output is correct
15 Correct 23 ms 2224 KB Output is correct
16 Correct 21 ms 2248 KB Output is correct
17 Correct 12 ms 2260 KB Output is correct
18 Correct 19 ms 2260 KB Output is correct
19 Correct 16 ms 2168 KB Output is correct
20 Correct 20 ms 2260 KB Output is correct
21 Correct 43 ms 2252 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 37 ms 2248 KB Output is correct
24 Correct 50 ms 2264 KB Output is correct
25 Correct 56 ms 2268 KB Output is correct
26 Correct 56 ms 2280 KB Output is correct
27 Correct 60 ms 2276 KB Output is correct
28 Correct 52 ms 2308 KB Output is correct
29 Correct 55 ms 2172 KB Output is correct
30 Correct 56 ms 2180 KB Output is correct
31 Correct 57 ms 2272 KB Output is correct
32 Correct 53 ms 2252 KB Output is correct
33 Correct 52 ms 2284 KB Output is correct
34 Correct 65 ms 2156 KB Output is correct
35 Correct 53 ms 2168 KB Output is correct
36 Correct 59 ms 2284 KB Output is correct
37 Correct 114 ms 2444 KB Output is correct
38 Correct 128 ms 2444 KB Output is correct
39 Correct 139 ms 2484 KB Output is correct
40 Correct 206 ms 2552 KB Output is correct
41 Correct 143 ms 2428 KB Output is correct
42 Correct 171 ms 2540 KB Output is correct
43 Correct 206 ms 2844 KB Output is correct
44 Correct 177 ms 2840 KB Output is correct
45 Correct 178 ms 2796 KB Output is correct
46 Correct 178 ms 2288 KB Output is correct
47 Correct 166 ms 2504 KB Output is correct
48 Correct 170 ms 2724 KB Output is correct
49 Correct 146 ms 2552 KB Output is correct
50 Correct 195 ms 2500 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 209 ms 2892 KB Output is correct
53 Correct 205 ms 2680 KB Output is correct
54 Correct 264 ms 2836 KB Output is correct
55 Correct 278 ms 3180 KB Output is correct
56 Correct 206 ms 2840 KB Output is correct
57 Correct 299 ms 3320 KB Output is correct
58 Correct 265 ms 2864 KB Output is correct
59 Correct 244 ms 2940 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 261 ms 3060 KB Output is correct
62 Correct 239 ms 3136 KB Output is correct
63 Correct 269 ms 3184 KB Output is correct
64 Correct 251 ms 3224 KB Output is correct
65 Correct 152 ms 2424 KB Output is correct
66 Correct 170 ms 2500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2220 KB Output is correct
2 Correct 5 ms 2228 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 8 ms 2252 KB Output is correct
6 Correct 7 ms 2264 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 7 ms 2272 KB Output is correct
9 Correct 6 ms 2264 KB Output is correct
10 Correct 22 ms 2264 KB Output is correct
11 Correct 20 ms 2252 KB Output is correct
12 Correct 24 ms 2172 KB Output is correct
13 Correct 18 ms 2220 KB Output is correct
14 Correct 21 ms 2264 KB Output is correct
15 Correct 23 ms 2224 KB Output is correct
16 Correct 21 ms 2248 KB Output is correct
17 Correct 12 ms 2260 KB Output is correct
18 Correct 19 ms 2260 KB Output is correct
19 Correct 16 ms 2168 KB Output is correct
20 Correct 20 ms 2260 KB Output is correct
21 Correct 43 ms 2252 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 37 ms 2248 KB Output is correct
24 Correct 50 ms 2264 KB Output is correct
25 Correct 56 ms 2268 KB Output is correct
26 Correct 56 ms 2280 KB Output is correct
27 Correct 60 ms 2276 KB Output is correct
28 Correct 52 ms 2308 KB Output is correct
29 Correct 55 ms 2172 KB Output is correct
30 Correct 56 ms 2180 KB Output is correct
31 Correct 57 ms 2272 KB Output is correct
32 Correct 53 ms 2252 KB Output is correct
33 Correct 52 ms 2284 KB Output is correct
34 Correct 65 ms 2156 KB Output is correct
35 Correct 53 ms 2168 KB Output is correct
36 Correct 59 ms 2284 KB Output is correct
37 Correct 114 ms 2444 KB Output is correct
38 Correct 128 ms 2444 KB Output is correct
39 Correct 139 ms 2484 KB Output is correct
40 Correct 206 ms 2552 KB Output is correct
41 Correct 143 ms 2428 KB Output is correct
42 Correct 171 ms 2540 KB Output is correct
43 Correct 206 ms 2844 KB Output is correct
44 Correct 177 ms 2840 KB Output is correct
45 Correct 178 ms 2796 KB Output is correct
46 Correct 178 ms 2288 KB Output is correct
47 Correct 166 ms 2504 KB Output is correct
48 Correct 170 ms 2724 KB Output is correct
49 Correct 146 ms 2552 KB Output is correct
50 Correct 195 ms 2500 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 209 ms 2892 KB Output is correct
53 Correct 205 ms 2680 KB Output is correct
54 Correct 264 ms 2836 KB Output is correct
55 Correct 278 ms 3180 KB Output is correct
56 Correct 206 ms 2840 KB Output is correct
57 Correct 299 ms 3320 KB Output is correct
58 Correct 265 ms 2864 KB Output is correct
59 Correct 244 ms 2940 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 261 ms 3060 KB Output is correct
62 Correct 239 ms 3136 KB Output is correct
63 Correct 269 ms 3184 KB Output is correct
64 Correct 251 ms 3224 KB Output is correct
65 Correct 152 ms 2424 KB Output is correct
66 Correct 170 ms 2500 KB Output is correct
67 Correct 307 ms 3108 KB Output is correct
68 Correct 106 ms 1264 KB Output is correct
69 Correct 555 ms 4212 KB Output is correct
70 Correct 449 ms 3444 KB Output is correct
71 Correct 412 ms 3436 KB Output is correct
72 Correct 434 ms 2800 KB Output is correct
73 Correct 429 ms 2672 KB Output is correct
74 Correct 593 ms 4444 KB Output is correct
75 Correct 507 ms 3932 KB Output is correct
76 Correct 616 ms 4336 KB Output is correct
77 Correct 583 ms 4440 KB Output is correct