#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[200005],res[200005],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(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 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 |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 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 |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
296 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
420 KB |
Output is correct |
25 |
Correct |
2 ms |
460 KB |
Output is correct |
26 |
Correct |
2 ms |
472 KB |
Output is correct |
27 |
Correct |
2 ms |
460 KB |
Output is correct |
28 |
Correct |
2 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 |
428 KB |
Output is correct |
32 |
Correct |
2 ms |
428 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
2 ms |
432 KB |
Output is correct |
35 |
Correct |
2 ms |
428 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 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 |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
296 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
420 KB |
Output is correct |
25 |
Correct |
2 ms |
460 KB |
Output is correct |
26 |
Correct |
2 ms |
472 KB |
Output is correct |
27 |
Correct |
2 ms |
460 KB |
Output is correct |
28 |
Correct |
2 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 |
428 KB |
Output is correct |
32 |
Correct |
2 ms |
428 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
2 ms |
432 KB |
Output is correct |
35 |
Correct |
2 ms |
428 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
9 ms |
856 KB |
Output is correct |
38 |
Correct |
8 ms |
844 KB |
Output is correct |
39 |
Correct |
25 ms |
1276 KB |
Output is correct |
40 |
Correct |
17 ms |
1076 KB |
Output is correct |
41 |
Correct |
32 ms |
1356 KB |
Output is correct |
42 |
Correct |
14 ms |
1056 KB |
Output is correct |
43 |
Correct |
25 ms |
1544 KB |
Output is correct |
44 |
Correct |
27 ms |
1576 KB |
Output is correct |
45 |
Correct |
28 ms |
1560 KB |
Output is correct |
46 |
Correct |
15 ms |
716 KB |
Output is correct |
47 |
Correct |
16 ms |
1076 KB |
Output is correct |
48 |
Correct |
38 ms |
1636 KB |
Output is correct |
49 |
Correct |
31 ms |
1268 KB |
Output is correct |
50 |
Correct |
17 ms |
1100 KB |
Output is correct |
51 |
Correct |
3 ms |
556 KB |
Output is correct |
52 |
Correct |
41 ms |
1900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 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 |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
296 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
420 KB |
Output is correct |
25 |
Correct |
2 ms |
460 KB |
Output is correct |
26 |
Correct |
2 ms |
472 KB |
Output is correct |
27 |
Correct |
2 ms |
460 KB |
Output is correct |
28 |
Correct |
2 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 |
428 KB |
Output is correct |
32 |
Correct |
2 ms |
428 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
2 ms |
432 KB |
Output is correct |
35 |
Correct |
2 ms |
428 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
9 ms |
856 KB |
Output is correct |
38 |
Correct |
8 ms |
844 KB |
Output is correct |
39 |
Correct |
25 ms |
1276 KB |
Output is correct |
40 |
Correct |
17 ms |
1076 KB |
Output is correct |
41 |
Correct |
32 ms |
1356 KB |
Output is correct |
42 |
Correct |
14 ms |
1056 KB |
Output is correct |
43 |
Correct |
25 ms |
1544 KB |
Output is correct |
44 |
Correct |
27 ms |
1576 KB |
Output is correct |
45 |
Correct |
28 ms |
1560 KB |
Output is correct |
46 |
Correct |
15 ms |
716 KB |
Output is correct |
47 |
Correct |
16 ms |
1076 KB |
Output is correct |
48 |
Correct |
38 ms |
1636 KB |
Output is correct |
49 |
Correct |
31 ms |
1268 KB |
Output is correct |
50 |
Correct |
17 ms |
1100 KB |
Output is correct |
51 |
Correct |
3 ms |
556 KB |
Output is correct |
52 |
Correct |
41 ms |
1900 KB |
Output is correct |
53 |
Correct |
26 ms |
1400 KB |
Output is correct |
54 |
Correct |
39 ms |
1660 KB |
Output is correct |
55 |
Correct |
74 ms |
2788 KB |
Output is correct |
56 |
Correct |
37 ms |
1688 KB |
Output is correct |
57 |
Correct |
76 ms |
2892 KB |
Output is correct |
58 |
Correct |
42 ms |
1772 KB |
Output is correct |
59 |
Correct |
57 ms |
2112 KB |
Output is correct |
60 |
Correct |
7 ms |
680 KB |
Output is correct |
61 |
Correct |
64 ms |
2288 KB |
Output is correct |
62 |
Correct |
69 ms |
2560 KB |
Output is correct |
63 |
Correct |
65 ms |
2716 KB |
Output is correct |
64 |
Correct |
63 ms |
2636 KB |
Output is correct |
65 |
Correct |
28 ms |
972 KB |
Output is correct |
66 |
Correct |
34 ms |
1252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 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 |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
296 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
296 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
420 KB |
Output is correct |
25 |
Correct |
2 ms |
460 KB |
Output is correct |
26 |
Correct |
2 ms |
472 KB |
Output is correct |
27 |
Correct |
2 ms |
460 KB |
Output is correct |
28 |
Correct |
2 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 |
428 KB |
Output is correct |
32 |
Correct |
2 ms |
428 KB |
Output is correct |
33 |
Correct |
2 ms |
460 KB |
Output is correct |
34 |
Correct |
2 ms |
432 KB |
Output is correct |
35 |
Correct |
2 ms |
428 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
9 ms |
856 KB |
Output is correct |
38 |
Correct |
8 ms |
844 KB |
Output is correct |
39 |
Correct |
25 ms |
1276 KB |
Output is correct |
40 |
Correct |
17 ms |
1076 KB |
Output is correct |
41 |
Correct |
32 ms |
1356 KB |
Output is correct |
42 |
Correct |
14 ms |
1056 KB |
Output is correct |
43 |
Correct |
25 ms |
1544 KB |
Output is correct |
44 |
Correct |
27 ms |
1576 KB |
Output is correct |
45 |
Correct |
28 ms |
1560 KB |
Output is correct |
46 |
Correct |
15 ms |
716 KB |
Output is correct |
47 |
Correct |
16 ms |
1076 KB |
Output is correct |
48 |
Correct |
38 ms |
1636 KB |
Output is correct |
49 |
Correct |
31 ms |
1268 KB |
Output is correct |
50 |
Correct |
17 ms |
1100 KB |
Output is correct |
51 |
Correct |
3 ms |
556 KB |
Output is correct |
52 |
Correct |
41 ms |
1900 KB |
Output is correct |
53 |
Correct |
26 ms |
1400 KB |
Output is correct |
54 |
Correct |
39 ms |
1660 KB |
Output is correct |
55 |
Correct |
74 ms |
2788 KB |
Output is correct |
56 |
Correct |
37 ms |
1688 KB |
Output is correct |
57 |
Correct |
76 ms |
2892 KB |
Output is correct |
58 |
Correct |
42 ms |
1772 KB |
Output is correct |
59 |
Correct |
57 ms |
2112 KB |
Output is correct |
60 |
Correct |
7 ms |
680 KB |
Output is correct |
61 |
Correct |
64 ms |
2288 KB |
Output is correct |
62 |
Correct |
69 ms |
2560 KB |
Output is correct |
63 |
Correct |
65 ms |
2716 KB |
Output is correct |
64 |
Correct |
63 ms |
2636 KB |
Output is correct |
65 |
Correct |
28 ms |
972 KB |
Output is correct |
66 |
Correct |
34 ms |
1252 KB |
Output is correct |
67 |
Correct |
69 ms |
2176 KB |
Output is correct |
68 |
Correct |
17 ms |
1196 KB |
Output is correct |
69 |
Runtime error |
28 ms |
3508 KB |
Execution killed with signal 11 |
70 |
Halted |
0 ms |
0 KB |
- |