#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n;
ll a[250002];
ll sum = 0;
ll cnt[250002];
ll mp[250002];
void add(int x) {
for (int i = sum; i >= 0; i--) {
cnt[i + x] += cnt[i];
if (cnt[i + x] >= mod) cnt[i + x] -= mod;
}
sum += x;
}
void sub(int x) {
for (int i = 0; i <= sum; i++) {
cnt[i + x] += (mod - cnt[i]);
if (cnt[i + x] >= mod) cnt[i + x] -= mod;
}
sum -= x;
}
int main() {
cin>>n;
cnt[0] = 1;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
add(a[i]);
}
if(sum&1 || !cnt[sum/2])
{
cout<<"0\n";
return 0;
}
for(ll i=1;i<=n;i++)
{
sub(a[i]);
ll v = 2;
if(sum & 1)
v--;
for(ll j=v; j<=sum; j+=2)
if(cnt[(sum + j) / 2 - j])
mp[j] ++;
add(a[i]);
}
vector<ll> ans;
for(ll i=1;i<=sum;i++)
if(mp[i] == n)
ans.push_back(i);
cout<<ans.size()<<endl;
for(auto it:ans)
cout<<it<<" ";
cout<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
440 KB |
Output is correct |
26 |
Correct |
4 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
468 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
436 KB |
Output is correct |
33 |
Correct |
4 ms |
468 KB |
Output is correct |
34 |
Correct |
4 ms |
468 KB |
Output is correct |
35 |
Correct |
4 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
440 KB |
Output is correct |
26 |
Correct |
4 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
468 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
436 KB |
Output is correct |
33 |
Correct |
4 ms |
468 KB |
Output is correct |
34 |
Correct |
4 ms |
468 KB |
Output is correct |
35 |
Correct |
4 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
37 |
Correct |
15 ms |
884 KB |
Output is correct |
38 |
Correct |
13 ms |
852 KB |
Output is correct |
39 |
Correct |
48 ms |
1276 KB |
Output is correct |
40 |
Correct |
28 ms |
1096 KB |
Output is correct |
41 |
Correct |
61 ms |
1324 KB |
Output is correct |
42 |
Correct |
24 ms |
1052 KB |
Output is correct |
43 |
Correct |
44 ms |
1564 KB |
Output is correct |
44 |
Correct |
45 ms |
1568 KB |
Output is correct |
45 |
Correct |
49 ms |
1700 KB |
Output is correct |
46 |
Correct |
28 ms |
724 KB |
Output is correct |
47 |
Correct |
27 ms |
1084 KB |
Output is correct |
48 |
Correct |
48 ms |
1612 KB |
Output is correct |
49 |
Correct |
49 ms |
1372 KB |
Output is correct |
50 |
Correct |
27 ms |
1100 KB |
Output is correct |
51 |
Correct |
5 ms |
468 KB |
Output is correct |
52 |
Correct |
62 ms |
1836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
440 KB |
Output is correct |
26 |
Correct |
4 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
468 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
436 KB |
Output is correct |
33 |
Correct |
4 ms |
468 KB |
Output is correct |
34 |
Correct |
4 ms |
468 KB |
Output is correct |
35 |
Correct |
4 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
37 |
Correct |
15 ms |
884 KB |
Output is correct |
38 |
Correct |
13 ms |
852 KB |
Output is correct |
39 |
Correct |
48 ms |
1276 KB |
Output is correct |
40 |
Correct |
28 ms |
1096 KB |
Output is correct |
41 |
Correct |
61 ms |
1324 KB |
Output is correct |
42 |
Correct |
24 ms |
1052 KB |
Output is correct |
43 |
Correct |
44 ms |
1564 KB |
Output is correct |
44 |
Correct |
45 ms |
1568 KB |
Output is correct |
45 |
Correct |
49 ms |
1700 KB |
Output is correct |
46 |
Correct |
28 ms |
724 KB |
Output is correct |
47 |
Correct |
27 ms |
1084 KB |
Output is correct |
48 |
Correct |
48 ms |
1612 KB |
Output is correct |
49 |
Correct |
49 ms |
1372 KB |
Output is correct |
50 |
Correct |
27 ms |
1100 KB |
Output is correct |
51 |
Correct |
5 ms |
468 KB |
Output is correct |
52 |
Correct |
62 ms |
1836 KB |
Output is correct |
53 |
Correct |
52 ms |
1416 KB |
Output is correct |
54 |
Correct |
63 ms |
1684 KB |
Output is correct |
55 |
Correct |
122 ms |
2804 KB |
Output is correct |
56 |
Correct |
53 ms |
1704 KB |
Output is correct |
57 |
Correct |
135 ms |
2888 KB |
Output is correct |
58 |
Correct |
71 ms |
1768 KB |
Output is correct |
59 |
Correct |
86 ms |
2140 KB |
Output is correct |
60 |
Correct |
11 ms |
756 KB |
Output is correct |
61 |
Correct |
101 ms |
2284 KB |
Output is correct |
62 |
Correct |
108 ms |
2560 KB |
Output is correct |
63 |
Correct |
110 ms |
2684 KB |
Output is correct |
64 |
Correct |
103 ms |
2668 KB |
Output is correct |
65 |
Correct |
48 ms |
1076 KB |
Output is correct |
66 |
Correct |
53 ms |
1256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
440 KB |
Output is correct |
26 |
Correct |
4 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
468 KB |
Output is correct |
28 |
Correct |
4 ms |
468 KB |
Output is correct |
29 |
Correct |
4 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
436 KB |
Output is correct |
33 |
Correct |
4 ms |
468 KB |
Output is correct |
34 |
Correct |
4 ms |
468 KB |
Output is correct |
35 |
Correct |
4 ms |
468 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
37 |
Correct |
15 ms |
884 KB |
Output is correct |
38 |
Correct |
13 ms |
852 KB |
Output is correct |
39 |
Correct |
48 ms |
1276 KB |
Output is correct |
40 |
Correct |
28 ms |
1096 KB |
Output is correct |
41 |
Correct |
61 ms |
1324 KB |
Output is correct |
42 |
Correct |
24 ms |
1052 KB |
Output is correct |
43 |
Correct |
44 ms |
1564 KB |
Output is correct |
44 |
Correct |
45 ms |
1568 KB |
Output is correct |
45 |
Correct |
49 ms |
1700 KB |
Output is correct |
46 |
Correct |
28 ms |
724 KB |
Output is correct |
47 |
Correct |
27 ms |
1084 KB |
Output is correct |
48 |
Correct |
48 ms |
1612 KB |
Output is correct |
49 |
Correct |
49 ms |
1372 KB |
Output is correct |
50 |
Correct |
27 ms |
1100 KB |
Output is correct |
51 |
Correct |
5 ms |
468 KB |
Output is correct |
52 |
Correct |
62 ms |
1836 KB |
Output is correct |
53 |
Correct |
52 ms |
1416 KB |
Output is correct |
54 |
Correct |
63 ms |
1684 KB |
Output is correct |
55 |
Correct |
122 ms |
2804 KB |
Output is correct |
56 |
Correct |
53 ms |
1704 KB |
Output is correct |
57 |
Correct |
135 ms |
2888 KB |
Output is correct |
58 |
Correct |
71 ms |
1768 KB |
Output is correct |
59 |
Correct |
86 ms |
2140 KB |
Output is correct |
60 |
Correct |
11 ms |
756 KB |
Output is correct |
61 |
Correct |
101 ms |
2284 KB |
Output is correct |
62 |
Correct |
108 ms |
2560 KB |
Output is correct |
63 |
Correct |
110 ms |
2684 KB |
Output is correct |
64 |
Correct |
103 ms |
2668 KB |
Output is correct |
65 |
Correct |
48 ms |
1076 KB |
Output is correct |
66 |
Correct |
53 ms |
1256 KB |
Output is correct |
67 |
Correct |
101 ms |
2196 KB |
Output is correct |
68 |
Correct |
33 ms |
1200 KB |
Output is correct |
69 |
Correct |
342 ms |
5136 KB |
Output is correct |
70 |
Correct |
242 ms |
3324 KB |
Output is correct |
71 |
Correct |
191 ms |
3216 KB |
Output is correct |
72 |
Correct |
194 ms |
2272 KB |
Output is correct |
73 |
Correct |
199 ms |
2308 KB |
Output is correct |
74 |
Correct |
349 ms |
5464 KB |
Output is correct |
75 |
Correct |
287 ms |
4296 KB |
Output is correct |
76 |
Correct |
373 ms |
5624 KB |
Output is correct |
77 |
Correct |
396 ms |
5788 KB |
Output is correct |