#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const int maxn = 555;
ll sum = 0;
ll dp[maxn*maxn];
void add(ll x) {
for (int i=sum; i>=0; i--) {
dp[i+x] += dp[i];
}
sum += x;
}
void sub(ll x) {
for (int i=0; i<=sum; i++) {
dp[i+x] -= dp[i];
}
sum -= x;
}
bool fail[maxn*maxn];
int n;
ll a[maxn];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
dp[0]=1;
cin>>n;
for (int i=0; i<n; i++) {
cin>>a[i];
add(a[i]);
}
if (sum%2) out(0);
if (dp[sum/2]==0) out(0);
for (int i=0; i<n; i++) {
sub(a[i]);
for (int x=1; x<=500*500; x++) {
if ((sum+x)%2==1) {
fail[x]=true;
}
if ((sum+x)%2==0 && dp[(sum+x)/2]==0) {
fail[x]=true;
}
}
add(a[i]);
}
vector<int> ans;
for (int i=1; i<=500*500; i++) {
if (!fail[i]) ans.push_back(i);
}
cout<<ans.size()<<"\n";
for (int x: ans) cout<<x<<" ";
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
7 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
6 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
7 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
6 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
620 KB |
Output is correct |
10 |
Correct |
12 ms |
620 KB |
Output is correct |
11 |
Correct |
12 ms |
620 KB |
Output is correct |
12 |
Correct |
12 ms |
620 KB |
Output is correct |
13 |
Correct |
16 ms |
620 KB |
Output is correct |
14 |
Correct |
11 ms |
620 KB |
Output is correct |
15 |
Correct |
11 ms |
620 KB |
Output is correct |
16 |
Correct |
12 ms |
620 KB |
Output is correct |
17 |
Correct |
8 ms |
620 KB |
Output is correct |
18 |
Correct |
10 ms |
620 KB |
Output is correct |
19 |
Correct |
11 ms |
640 KB |
Output is correct |
20 |
Correct |
12 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
7 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
6 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
620 KB |
Output is correct |
10 |
Correct |
12 ms |
620 KB |
Output is correct |
11 |
Correct |
12 ms |
620 KB |
Output is correct |
12 |
Correct |
12 ms |
620 KB |
Output is correct |
13 |
Correct |
16 ms |
620 KB |
Output is correct |
14 |
Correct |
11 ms |
620 KB |
Output is correct |
15 |
Correct |
11 ms |
620 KB |
Output is correct |
16 |
Correct |
12 ms |
620 KB |
Output is correct |
17 |
Correct |
8 ms |
620 KB |
Output is correct |
18 |
Correct |
10 ms |
620 KB |
Output is correct |
19 |
Correct |
11 ms |
640 KB |
Output is correct |
20 |
Correct |
12 ms |
620 KB |
Output is correct |
21 |
Correct |
24 ms |
620 KB |
Output is correct |
22 |
Correct |
27 ms |
620 KB |
Output is correct |
23 |
Correct |
22 ms |
748 KB |
Output is correct |
24 |
Correct |
37 ms |
620 KB |
Output is correct |
25 |
Correct |
37 ms |
664 KB |
Output is correct |
26 |
Correct |
37 ms |
748 KB |
Output is correct |
27 |
Correct |
38 ms |
748 KB |
Output is correct |
28 |
Correct |
49 ms |
748 KB |
Output is correct |
29 |
Correct |
39 ms |
620 KB |
Output is correct |
30 |
Correct |
38 ms |
620 KB |
Output is correct |
31 |
Correct |
39 ms |
748 KB |
Output is correct |
32 |
Correct |
37 ms |
620 KB |
Output is correct |
33 |
Correct |
39 ms |
620 KB |
Output is correct |
34 |
Correct |
37 ms |
620 KB |
Output is correct |
35 |
Correct |
38 ms |
620 KB |
Output is correct |
36 |
Correct |
37 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
7 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
6 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
620 KB |
Output is correct |
10 |
Correct |
12 ms |
620 KB |
Output is correct |
11 |
Correct |
12 ms |
620 KB |
Output is correct |
12 |
Correct |
12 ms |
620 KB |
Output is correct |
13 |
Correct |
16 ms |
620 KB |
Output is correct |
14 |
Correct |
11 ms |
620 KB |
Output is correct |
15 |
Correct |
11 ms |
620 KB |
Output is correct |
16 |
Correct |
12 ms |
620 KB |
Output is correct |
17 |
Correct |
8 ms |
620 KB |
Output is correct |
18 |
Correct |
10 ms |
620 KB |
Output is correct |
19 |
Correct |
11 ms |
640 KB |
Output is correct |
20 |
Correct |
12 ms |
620 KB |
Output is correct |
21 |
Correct |
24 ms |
620 KB |
Output is correct |
22 |
Correct |
27 ms |
620 KB |
Output is correct |
23 |
Correct |
22 ms |
748 KB |
Output is correct |
24 |
Correct |
37 ms |
620 KB |
Output is correct |
25 |
Correct |
37 ms |
664 KB |
Output is correct |
26 |
Correct |
37 ms |
748 KB |
Output is correct |
27 |
Correct |
38 ms |
748 KB |
Output is correct |
28 |
Correct |
49 ms |
748 KB |
Output is correct |
29 |
Correct |
39 ms |
620 KB |
Output is correct |
30 |
Correct |
38 ms |
620 KB |
Output is correct |
31 |
Correct |
39 ms |
748 KB |
Output is correct |
32 |
Correct |
37 ms |
620 KB |
Output is correct |
33 |
Correct |
39 ms |
620 KB |
Output is correct |
34 |
Correct |
37 ms |
620 KB |
Output is correct |
35 |
Correct |
38 ms |
620 KB |
Output is correct |
36 |
Correct |
37 ms |
620 KB |
Output is correct |
37 |
Correct |
78 ms |
876 KB |
Output is correct |
38 |
Correct |
81 ms |
1004 KB |
Output is correct |
39 |
Correct |
117 ms |
1260 KB |
Output is correct |
40 |
Correct |
117 ms |
1132 KB |
Output is correct |
41 |
Correct |
123 ms |
1132 KB |
Output is correct |
42 |
Correct |
104 ms |
1004 KB |
Output is correct |
43 |
Correct |
113 ms |
1516 KB |
Output is correct |
44 |
Correct |
110 ms |
1388 KB |
Output is correct |
45 |
Correct |
116 ms |
1388 KB |
Output is correct |
46 |
Correct |
112 ms |
1004 KB |
Output is correct |
47 |
Correct |
109 ms |
1132 KB |
Output is correct |
48 |
Correct |
119 ms |
1388 KB |
Output is correct |
49 |
Correct |
114 ms |
1132 KB |
Output is correct |
50 |
Correct |
113 ms |
1044 KB |
Output is correct |
51 |
Correct |
3 ms |
620 KB |
Output is correct |
52 |
Correct |
130 ms |
1644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
7 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
6 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
620 KB |
Output is correct |
10 |
Correct |
12 ms |
620 KB |
Output is correct |
11 |
Correct |
12 ms |
620 KB |
Output is correct |
12 |
Correct |
12 ms |
620 KB |
Output is correct |
13 |
Correct |
16 ms |
620 KB |
Output is correct |
14 |
Correct |
11 ms |
620 KB |
Output is correct |
15 |
Correct |
11 ms |
620 KB |
Output is correct |
16 |
Correct |
12 ms |
620 KB |
Output is correct |
17 |
Correct |
8 ms |
620 KB |
Output is correct |
18 |
Correct |
10 ms |
620 KB |
Output is correct |
19 |
Correct |
11 ms |
640 KB |
Output is correct |
20 |
Correct |
12 ms |
620 KB |
Output is correct |
21 |
Correct |
24 ms |
620 KB |
Output is correct |
22 |
Correct |
27 ms |
620 KB |
Output is correct |
23 |
Correct |
22 ms |
748 KB |
Output is correct |
24 |
Correct |
37 ms |
620 KB |
Output is correct |
25 |
Correct |
37 ms |
664 KB |
Output is correct |
26 |
Correct |
37 ms |
748 KB |
Output is correct |
27 |
Correct |
38 ms |
748 KB |
Output is correct |
28 |
Correct |
49 ms |
748 KB |
Output is correct |
29 |
Correct |
39 ms |
620 KB |
Output is correct |
30 |
Correct |
38 ms |
620 KB |
Output is correct |
31 |
Correct |
39 ms |
748 KB |
Output is correct |
32 |
Correct |
37 ms |
620 KB |
Output is correct |
33 |
Correct |
39 ms |
620 KB |
Output is correct |
34 |
Correct |
37 ms |
620 KB |
Output is correct |
35 |
Correct |
38 ms |
620 KB |
Output is correct |
36 |
Correct |
37 ms |
620 KB |
Output is correct |
37 |
Correct |
78 ms |
876 KB |
Output is correct |
38 |
Correct |
81 ms |
1004 KB |
Output is correct |
39 |
Correct |
117 ms |
1260 KB |
Output is correct |
40 |
Correct |
117 ms |
1132 KB |
Output is correct |
41 |
Correct |
123 ms |
1132 KB |
Output is correct |
42 |
Correct |
104 ms |
1004 KB |
Output is correct |
43 |
Correct |
113 ms |
1516 KB |
Output is correct |
44 |
Correct |
110 ms |
1388 KB |
Output is correct |
45 |
Correct |
116 ms |
1388 KB |
Output is correct |
46 |
Correct |
112 ms |
1004 KB |
Output is correct |
47 |
Correct |
109 ms |
1132 KB |
Output is correct |
48 |
Correct |
119 ms |
1388 KB |
Output is correct |
49 |
Correct |
114 ms |
1132 KB |
Output is correct |
50 |
Correct |
113 ms |
1044 KB |
Output is correct |
51 |
Correct |
3 ms |
620 KB |
Output is correct |
52 |
Correct |
130 ms |
1644 KB |
Output is correct |
53 |
Correct |
127 ms |
1260 KB |
Output is correct |
54 |
Correct |
157 ms |
1516 KB |
Output is correct |
55 |
Correct |
190 ms |
2196 KB |
Output is correct |
56 |
Correct |
141 ms |
1388 KB |
Output is correct |
57 |
Correct |
193 ms |
2160 KB |
Output is correct |
58 |
Correct |
157 ms |
1520 KB |
Output is correct |
59 |
Correct |
167 ms |
1648 KB |
Output is correct |
60 |
Correct |
7 ms |
876 KB |
Output is correct |
61 |
Correct |
171 ms |
1844 KB |
Output is correct |
62 |
Correct |
166 ms |
1904 KB |
Output is correct |
63 |
Correct |
175 ms |
2032 KB |
Output is correct |
64 |
Correct |
165 ms |
2056 KB |
Output is correct |
65 |
Correct |
143 ms |
1132 KB |
Output is correct |
66 |
Correct |
144 ms |
1132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
7 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
4 ms |
620 KB |
Output is correct |
8 |
Correct |
6 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
620 KB |
Output is correct |
10 |
Correct |
12 ms |
620 KB |
Output is correct |
11 |
Correct |
12 ms |
620 KB |
Output is correct |
12 |
Correct |
12 ms |
620 KB |
Output is correct |
13 |
Correct |
16 ms |
620 KB |
Output is correct |
14 |
Correct |
11 ms |
620 KB |
Output is correct |
15 |
Correct |
11 ms |
620 KB |
Output is correct |
16 |
Correct |
12 ms |
620 KB |
Output is correct |
17 |
Correct |
8 ms |
620 KB |
Output is correct |
18 |
Correct |
10 ms |
620 KB |
Output is correct |
19 |
Correct |
11 ms |
640 KB |
Output is correct |
20 |
Correct |
12 ms |
620 KB |
Output is correct |
21 |
Correct |
24 ms |
620 KB |
Output is correct |
22 |
Correct |
27 ms |
620 KB |
Output is correct |
23 |
Correct |
22 ms |
748 KB |
Output is correct |
24 |
Correct |
37 ms |
620 KB |
Output is correct |
25 |
Correct |
37 ms |
664 KB |
Output is correct |
26 |
Correct |
37 ms |
748 KB |
Output is correct |
27 |
Correct |
38 ms |
748 KB |
Output is correct |
28 |
Correct |
49 ms |
748 KB |
Output is correct |
29 |
Correct |
39 ms |
620 KB |
Output is correct |
30 |
Correct |
38 ms |
620 KB |
Output is correct |
31 |
Correct |
39 ms |
748 KB |
Output is correct |
32 |
Correct |
37 ms |
620 KB |
Output is correct |
33 |
Correct |
39 ms |
620 KB |
Output is correct |
34 |
Correct |
37 ms |
620 KB |
Output is correct |
35 |
Correct |
38 ms |
620 KB |
Output is correct |
36 |
Correct |
37 ms |
620 KB |
Output is correct |
37 |
Correct |
78 ms |
876 KB |
Output is correct |
38 |
Correct |
81 ms |
1004 KB |
Output is correct |
39 |
Correct |
117 ms |
1260 KB |
Output is correct |
40 |
Correct |
117 ms |
1132 KB |
Output is correct |
41 |
Correct |
123 ms |
1132 KB |
Output is correct |
42 |
Correct |
104 ms |
1004 KB |
Output is correct |
43 |
Correct |
113 ms |
1516 KB |
Output is correct |
44 |
Correct |
110 ms |
1388 KB |
Output is correct |
45 |
Correct |
116 ms |
1388 KB |
Output is correct |
46 |
Correct |
112 ms |
1004 KB |
Output is correct |
47 |
Correct |
109 ms |
1132 KB |
Output is correct |
48 |
Correct |
119 ms |
1388 KB |
Output is correct |
49 |
Correct |
114 ms |
1132 KB |
Output is correct |
50 |
Correct |
113 ms |
1044 KB |
Output is correct |
51 |
Correct |
3 ms |
620 KB |
Output is correct |
52 |
Correct |
130 ms |
1644 KB |
Output is correct |
53 |
Correct |
127 ms |
1260 KB |
Output is correct |
54 |
Correct |
157 ms |
1516 KB |
Output is correct |
55 |
Correct |
190 ms |
2196 KB |
Output is correct |
56 |
Correct |
141 ms |
1388 KB |
Output is correct |
57 |
Correct |
193 ms |
2160 KB |
Output is correct |
58 |
Correct |
157 ms |
1520 KB |
Output is correct |
59 |
Correct |
167 ms |
1648 KB |
Output is correct |
60 |
Correct |
7 ms |
876 KB |
Output is correct |
61 |
Correct |
171 ms |
1844 KB |
Output is correct |
62 |
Correct |
166 ms |
1904 KB |
Output is correct |
63 |
Correct |
175 ms |
2032 KB |
Output is correct |
64 |
Correct |
165 ms |
2056 KB |
Output is correct |
65 |
Correct |
143 ms |
1132 KB |
Output is correct |
66 |
Correct |
144 ms |
1132 KB |
Output is correct |
67 |
Correct |
195 ms |
1800 KB |
Output is correct |
68 |
Correct |
21 ms |
1388 KB |
Output is correct |
69 |
Correct |
342 ms |
3436 KB |
Output is correct |
70 |
Correct |
280 ms |
2544 KB |
Output is correct |
71 |
Correct |
275 ms |
2288 KB |
Output is correct |
72 |
Correct |
270 ms |
1644 KB |
Output is correct |
73 |
Correct |
266 ms |
1644 KB |
Output is correct |
74 |
Correct |
341 ms |
3692 KB |
Output is correct |
75 |
Correct |
316 ms |
3044 KB |
Output is correct |
76 |
Correct |
359 ms |
3692 KB |
Output is correct |
77 |
Correct |
359 ms |
3796 KB |
Output is correct |