#include <iostream>
#include <vector>
using namespace std;
int N,S;
int A[502];
int DP[260006];
vector<int> V;
bool flag[260006];
int main(){
cin>>N;
for(int i=0;i<N;i++){
cin>>A[i];
S+=A[i];
}
DP[0]=1;
for(int i=0;i<N;i++)
for(int j=S;j>=0;j--)
if(j-A[i]>=0)
DP[j]+=DP[j-A[i]];
for(int j=0;j<N;j++){
for(int k=A[j];k<=S;k++)
DP[k]-=DP[k-A[j]];
for(int i=1;i<S+1;i++){
int k=(S+i-A[j])/2;
if((S+i-A[j])%2==1 or !DP[k])
flag[i]=true;
}
for(int k=S;k>=A[j];k--)
DP[k]+=DP[k-A[j]];
}
for(int j=1;j<=S;j++)
if(!flag[j])
V.push_back(j);
if(S%2 or !DP[S/2])
V.clear();
cout<<V.size()<<"\n";
for(int x:V)
cout<<x<<" ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
6 ms |
424 KB |
Output is correct |
27 |
Correct |
6 ms |
376 KB |
Output is correct |
28 |
Correct |
6 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
6 ms |
376 KB |
Output is correct |
34 |
Correct |
6 ms |
376 KB |
Output is correct |
35 |
Correct |
6 ms |
420 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
6 ms |
424 KB |
Output is correct |
27 |
Correct |
6 ms |
376 KB |
Output is correct |
28 |
Correct |
6 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
6 ms |
376 KB |
Output is correct |
34 |
Correct |
6 ms |
376 KB |
Output is correct |
35 |
Correct |
6 ms |
420 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
19 ms |
632 KB |
Output is correct |
38 |
Correct |
19 ms |
592 KB |
Output is correct |
39 |
Correct |
61 ms |
676 KB |
Output is correct |
40 |
Correct |
37 ms |
760 KB |
Output is correct |
41 |
Correct |
76 ms |
636 KB |
Output is correct |
42 |
Correct |
32 ms |
648 KB |
Output is correct |
43 |
Correct |
55 ms |
1016 KB |
Output is correct |
44 |
Correct |
58 ms |
1016 KB |
Output is correct |
45 |
Correct |
58 ms |
1028 KB |
Output is correct |
46 |
Correct |
38 ms |
528 KB |
Output is correct |
47 |
Correct |
34 ms |
632 KB |
Output is correct |
48 |
Correct |
63 ms |
888 KB |
Output is correct |
49 |
Correct |
64 ms |
760 KB |
Output is correct |
50 |
Correct |
34 ms |
632 KB |
Output is correct |
51 |
Correct |
31 ms |
504 KB |
Output is correct |
52 |
Correct |
77 ms |
1132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
6 ms |
424 KB |
Output is correct |
27 |
Correct |
6 ms |
376 KB |
Output is correct |
28 |
Correct |
6 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
6 ms |
376 KB |
Output is correct |
34 |
Correct |
6 ms |
376 KB |
Output is correct |
35 |
Correct |
6 ms |
420 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
19 ms |
632 KB |
Output is correct |
38 |
Correct |
19 ms |
592 KB |
Output is correct |
39 |
Correct |
61 ms |
676 KB |
Output is correct |
40 |
Correct |
37 ms |
760 KB |
Output is correct |
41 |
Correct |
76 ms |
636 KB |
Output is correct |
42 |
Correct |
32 ms |
648 KB |
Output is correct |
43 |
Correct |
55 ms |
1016 KB |
Output is correct |
44 |
Correct |
58 ms |
1016 KB |
Output is correct |
45 |
Correct |
58 ms |
1028 KB |
Output is correct |
46 |
Correct |
38 ms |
528 KB |
Output is correct |
47 |
Correct |
34 ms |
632 KB |
Output is correct |
48 |
Correct |
63 ms |
888 KB |
Output is correct |
49 |
Correct |
64 ms |
760 KB |
Output is correct |
50 |
Correct |
34 ms |
632 KB |
Output is correct |
51 |
Correct |
31 ms |
504 KB |
Output is correct |
52 |
Correct |
77 ms |
1132 KB |
Output is correct |
53 |
Correct |
56 ms |
884 KB |
Output is correct |
54 |
Correct |
78 ms |
1028 KB |
Output is correct |
55 |
Correct |
153 ms |
1524 KB |
Output is correct |
56 |
Correct |
69 ms |
972 KB |
Output is correct |
57 |
Correct |
163 ms |
1652 KB |
Output is correct |
58 |
Correct |
85 ms |
1016 KB |
Output is correct |
59 |
Correct |
105 ms |
1144 KB |
Output is correct |
60 |
Correct |
82 ms |
632 KB |
Output is correct |
61 |
Correct |
118 ms |
1268 KB |
Output is correct |
62 |
Correct |
121 ms |
1388 KB |
Output is correct |
63 |
Correct |
132 ms |
1388 KB |
Output is correct |
64 |
Correct |
128 ms |
1468 KB |
Output is correct |
65 |
Correct |
67 ms |
632 KB |
Output is correct |
66 |
Correct |
72 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
376 KB |
Output is correct |
23 |
Correct |
3 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
376 KB |
Output is correct |
25 |
Correct |
6 ms |
376 KB |
Output is correct |
26 |
Correct |
6 ms |
424 KB |
Output is correct |
27 |
Correct |
6 ms |
376 KB |
Output is correct |
28 |
Correct |
6 ms |
376 KB |
Output is correct |
29 |
Correct |
7 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
6 ms |
376 KB |
Output is correct |
34 |
Correct |
6 ms |
376 KB |
Output is correct |
35 |
Correct |
6 ms |
420 KB |
Output is correct |
36 |
Correct |
5 ms |
376 KB |
Output is correct |
37 |
Correct |
19 ms |
632 KB |
Output is correct |
38 |
Correct |
19 ms |
592 KB |
Output is correct |
39 |
Correct |
61 ms |
676 KB |
Output is correct |
40 |
Correct |
37 ms |
760 KB |
Output is correct |
41 |
Correct |
76 ms |
636 KB |
Output is correct |
42 |
Correct |
32 ms |
648 KB |
Output is correct |
43 |
Correct |
55 ms |
1016 KB |
Output is correct |
44 |
Correct |
58 ms |
1016 KB |
Output is correct |
45 |
Correct |
58 ms |
1028 KB |
Output is correct |
46 |
Correct |
38 ms |
528 KB |
Output is correct |
47 |
Correct |
34 ms |
632 KB |
Output is correct |
48 |
Correct |
63 ms |
888 KB |
Output is correct |
49 |
Correct |
64 ms |
760 KB |
Output is correct |
50 |
Correct |
34 ms |
632 KB |
Output is correct |
51 |
Correct |
31 ms |
504 KB |
Output is correct |
52 |
Correct |
77 ms |
1132 KB |
Output is correct |
53 |
Correct |
56 ms |
884 KB |
Output is correct |
54 |
Correct |
78 ms |
1028 KB |
Output is correct |
55 |
Correct |
153 ms |
1524 KB |
Output is correct |
56 |
Correct |
69 ms |
972 KB |
Output is correct |
57 |
Correct |
163 ms |
1652 KB |
Output is correct |
58 |
Correct |
85 ms |
1016 KB |
Output is correct |
59 |
Correct |
105 ms |
1144 KB |
Output is correct |
60 |
Correct |
82 ms |
632 KB |
Output is correct |
61 |
Correct |
118 ms |
1268 KB |
Output is correct |
62 |
Correct |
121 ms |
1388 KB |
Output is correct |
63 |
Correct |
132 ms |
1388 KB |
Output is correct |
64 |
Correct |
128 ms |
1468 KB |
Output is correct |
65 |
Correct |
67 ms |
632 KB |
Output is correct |
66 |
Correct |
72 ms |
632 KB |
Output is correct |
67 |
Correct |
125 ms |
1272 KB |
Output is correct |
68 |
Correct |
257 ms |
968 KB |
Output is correct |
69 |
Correct |
410 ms |
2672 KB |
Output is correct |
70 |
Correct |
247 ms |
1780 KB |
Output is correct |
71 |
Correct |
239 ms |
1776 KB |
Output is correct |
72 |
Correct |
238 ms |
1016 KB |
Output is correct |
73 |
Correct |
242 ms |
992 KB |
Output is correct |
74 |
Correct |
429 ms |
2672 KB |
Output is correct |
75 |
Correct |
334 ms |
2332 KB |
Output is correct |
76 |
Correct |
472 ms |
2748 KB |
Output is correct |
77 |
Correct |
465 ms |
2876 KB |
Output is correct |