//Bismillahi-rahmani-rahim
#include <bits/stdc++.h>
using namespace std;
const int N = 250000;
int n;
int a[505], cnt[N+505];
int dp[N+505], d[N+505];
vector<int> ans;
int main() {
//Lebap;
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
int sum = 0;
for(int i=1;i<=n;i++) sum += a[i];
dp[0] = 1;
for(int i=1;i<=n;i++) {
for(int j=N;j>=0;j--) dp[j+a[i]] += dp[j];
}
if(sum%2!=0 || dp[sum/2]==0) return cout << "0", 0;
for(int i=1;i<=n;i++) {
memset(d,0,sizeof(d));
for(int j=0;j<=N;j++) {
d[j] += dp[j];
d[j+a[i]] -= d[j];
}
for(int j=0;j<=N;j++) {
if((sum-a[i]+j)%2==0 && sum-a[i]-j>=0 && d[(sum-a[i]-j)/2]!=0) cnt[j]++;
}
}
for(int i=1;i<=N;i++) if(cnt[i]==n) ans.push_back(i);
cout << ans.size() << endl;
for(auto i : ans) cout << i << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4952 KB |
Output is correct |
2 |
Correct |
16 ms |
4952 KB |
Output is correct |
3 |
Correct |
0 ms |
4952 KB |
Output is correct |
4 |
Correct |
6 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
4952 KB |
Output is correct |
6 |
Correct |
16 ms |
4952 KB |
Output is correct |
7 |
Correct |
9 ms |
4952 KB |
Output is correct |
8 |
Correct |
16 ms |
4952 KB |
Output is correct |
9 |
Correct |
19 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4952 KB |
Output is correct |
2 |
Correct |
16 ms |
4952 KB |
Output is correct |
3 |
Correct |
0 ms |
4952 KB |
Output is correct |
4 |
Correct |
6 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
4952 KB |
Output is correct |
6 |
Correct |
16 ms |
4952 KB |
Output is correct |
7 |
Correct |
9 ms |
4952 KB |
Output is correct |
8 |
Correct |
16 ms |
4952 KB |
Output is correct |
9 |
Correct |
19 ms |
4952 KB |
Output is correct |
10 |
Correct |
53 ms |
4952 KB |
Output is correct |
11 |
Correct |
43 ms |
4952 KB |
Output is correct |
12 |
Correct |
53 ms |
4952 KB |
Output is correct |
13 |
Correct |
36 ms |
4952 KB |
Output is correct |
14 |
Correct |
49 ms |
4952 KB |
Output is correct |
15 |
Correct |
63 ms |
4952 KB |
Output is correct |
16 |
Correct |
49 ms |
4952 KB |
Output is correct |
17 |
Correct |
29 ms |
4952 KB |
Output is correct |
18 |
Correct |
49 ms |
4952 KB |
Output is correct |
19 |
Correct |
36 ms |
4952 KB |
Output is correct |
20 |
Correct |
46 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4952 KB |
Output is correct |
2 |
Correct |
16 ms |
4952 KB |
Output is correct |
3 |
Correct |
0 ms |
4952 KB |
Output is correct |
4 |
Correct |
6 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
4952 KB |
Output is correct |
6 |
Correct |
16 ms |
4952 KB |
Output is correct |
7 |
Correct |
9 ms |
4952 KB |
Output is correct |
8 |
Correct |
16 ms |
4952 KB |
Output is correct |
9 |
Correct |
19 ms |
4952 KB |
Output is correct |
10 |
Correct |
53 ms |
4952 KB |
Output is correct |
11 |
Correct |
43 ms |
4952 KB |
Output is correct |
12 |
Correct |
53 ms |
4952 KB |
Output is correct |
13 |
Correct |
36 ms |
4952 KB |
Output is correct |
14 |
Correct |
49 ms |
4952 KB |
Output is correct |
15 |
Correct |
63 ms |
4952 KB |
Output is correct |
16 |
Correct |
49 ms |
4952 KB |
Output is correct |
17 |
Correct |
29 ms |
4952 KB |
Output is correct |
18 |
Correct |
49 ms |
4952 KB |
Output is correct |
19 |
Correct |
36 ms |
4952 KB |
Output is correct |
20 |
Correct |
46 ms |
4952 KB |
Output is correct |
21 |
Correct |
96 ms |
4952 KB |
Output is correct |
22 |
Correct |
113 ms |
4952 KB |
Output is correct |
23 |
Correct |
73 ms |
4952 KB |
Output is correct |
24 |
Correct |
163 ms |
4952 KB |
Output is correct |
25 |
Correct |
133 ms |
4952 KB |
Output is correct |
26 |
Correct |
156 ms |
4952 KB |
Output is correct |
27 |
Correct |
123 ms |
4952 KB |
Output is correct |
28 |
Correct |
133 ms |
4952 KB |
Output is correct |
29 |
Correct |
106 ms |
4952 KB |
Output is correct |
30 |
Correct |
119 ms |
4952 KB |
Output is correct |
31 |
Correct |
156 ms |
4952 KB |
Output is correct |
32 |
Correct |
129 ms |
4952 KB |
Output is correct |
33 |
Correct |
136 ms |
4952 KB |
Output is correct |
34 |
Correct |
169 ms |
4952 KB |
Output is correct |
35 |
Correct |
126 ms |
4952 KB |
Output is correct |
36 |
Correct |
153 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4952 KB |
Output is correct |
2 |
Correct |
16 ms |
4952 KB |
Output is correct |
3 |
Correct |
0 ms |
4952 KB |
Output is correct |
4 |
Correct |
6 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
4952 KB |
Output is correct |
6 |
Correct |
16 ms |
4952 KB |
Output is correct |
7 |
Correct |
9 ms |
4952 KB |
Output is correct |
8 |
Correct |
16 ms |
4952 KB |
Output is correct |
9 |
Correct |
19 ms |
4952 KB |
Output is correct |
10 |
Correct |
53 ms |
4952 KB |
Output is correct |
11 |
Correct |
43 ms |
4952 KB |
Output is correct |
12 |
Correct |
53 ms |
4952 KB |
Output is correct |
13 |
Correct |
36 ms |
4952 KB |
Output is correct |
14 |
Correct |
49 ms |
4952 KB |
Output is correct |
15 |
Correct |
63 ms |
4952 KB |
Output is correct |
16 |
Correct |
49 ms |
4952 KB |
Output is correct |
17 |
Correct |
29 ms |
4952 KB |
Output is correct |
18 |
Correct |
49 ms |
4952 KB |
Output is correct |
19 |
Correct |
36 ms |
4952 KB |
Output is correct |
20 |
Correct |
46 ms |
4952 KB |
Output is correct |
21 |
Correct |
96 ms |
4952 KB |
Output is correct |
22 |
Correct |
113 ms |
4952 KB |
Output is correct |
23 |
Correct |
73 ms |
4952 KB |
Output is correct |
24 |
Correct |
163 ms |
4952 KB |
Output is correct |
25 |
Correct |
133 ms |
4952 KB |
Output is correct |
26 |
Correct |
156 ms |
4952 KB |
Output is correct |
27 |
Correct |
123 ms |
4952 KB |
Output is correct |
28 |
Correct |
133 ms |
4952 KB |
Output is correct |
29 |
Correct |
106 ms |
4952 KB |
Output is correct |
30 |
Correct |
119 ms |
4952 KB |
Output is correct |
31 |
Correct |
156 ms |
4952 KB |
Output is correct |
32 |
Correct |
129 ms |
4952 KB |
Output is correct |
33 |
Correct |
136 ms |
4952 KB |
Output is correct |
34 |
Correct |
169 ms |
4952 KB |
Output is correct |
35 |
Correct |
126 ms |
4952 KB |
Output is correct |
36 |
Correct |
153 ms |
4952 KB |
Output is correct |
37 |
Correct |
269 ms |
5092 KB |
Output is correct |
38 |
Correct |
313 ms |
5092 KB |
Output is correct |
39 |
Correct |
346 ms |
4952 KB |
Output is correct |
40 |
Correct |
453 ms |
5092 KB |
Output is correct |
41 |
Correct |
439 ms |
4952 KB |
Output is correct |
42 |
Correct |
386 ms |
5092 KB |
Output is correct |
43 |
Correct |
313 ms |
5224 KB |
Output is correct |
44 |
Correct |
346 ms |
5224 KB |
Output is correct |
45 |
Correct |
349 ms |
5224 KB |
Output is correct |
46 |
Correct |
419 ms |
4952 KB |
Output is correct |
47 |
Correct |
369 ms |
5092 KB |
Output is correct |
48 |
Correct |
416 ms |
5224 KB |
Output is correct |
49 |
Correct |
356 ms |
5092 KB |
Output is correct |
50 |
Correct |
326 ms |
5092 KB |
Output is correct |
51 |
Correct |
73 ms |
4952 KB |
Output is correct |
52 |
Correct |
403 ms |
5224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4952 KB |
Output is correct |
2 |
Correct |
16 ms |
4952 KB |
Output is correct |
3 |
Correct |
0 ms |
4952 KB |
Output is correct |
4 |
Correct |
6 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
4952 KB |
Output is correct |
6 |
Correct |
16 ms |
4952 KB |
Output is correct |
7 |
Correct |
9 ms |
4952 KB |
Output is correct |
8 |
Correct |
16 ms |
4952 KB |
Output is correct |
9 |
Correct |
19 ms |
4952 KB |
Output is correct |
10 |
Correct |
53 ms |
4952 KB |
Output is correct |
11 |
Correct |
43 ms |
4952 KB |
Output is correct |
12 |
Correct |
53 ms |
4952 KB |
Output is correct |
13 |
Correct |
36 ms |
4952 KB |
Output is correct |
14 |
Correct |
49 ms |
4952 KB |
Output is correct |
15 |
Correct |
63 ms |
4952 KB |
Output is correct |
16 |
Correct |
49 ms |
4952 KB |
Output is correct |
17 |
Correct |
29 ms |
4952 KB |
Output is correct |
18 |
Correct |
49 ms |
4952 KB |
Output is correct |
19 |
Correct |
36 ms |
4952 KB |
Output is correct |
20 |
Correct |
46 ms |
4952 KB |
Output is correct |
21 |
Correct |
96 ms |
4952 KB |
Output is correct |
22 |
Correct |
113 ms |
4952 KB |
Output is correct |
23 |
Correct |
73 ms |
4952 KB |
Output is correct |
24 |
Correct |
163 ms |
4952 KB |
Output is correct |
25 |
Correct |
133 ms |
4952 KB |
Output is correct |
26 |
Correct |
156 ms |
4952 KB |
Output is correct |
27 |
Correct |
123 ms |
4952 KB |
Output is correct |
28 |
Correct |
133 ms |
4952 KB |
Output is correct |
29 |
Correct |
106 ms |
4952 KB |
Output is correct |
30 |
Correct |
119 ms |
4952 KB |
Output is correct |
31 |
Correct |
156 ms |
4952 KB |
Output is correct |
32 |
Correct |
129 ms |
4952 KB |
Output is correct |
33 |
Correct |
136 ms |
4952 KB |
Output is correct |
34 |
Correct |
169 ms |
4952 KB |
Output is correct |
35 |
Correct |
126 ms |
4952 KB |
Output is correct |
36 |
Correct |
153 ms |
4952 KB |
Output is correct |
37 |
Correct |
269 ms |
5092 KB |
Output is correct |
38 |
Correct |
313 ms |
5092 KB |
Output is correct |
39 |
Correct |
346 ms |
4952 KB |
Output is correct |
40 |
Correct |
453 ms |
5092 KB |
Output is correct |
41 |
Correct |
439 ms |
4952 KB |
Output is correct |
42 |
Correct |
386 ms |
5092 KB |
Output is correct |
43 |
Correct |
313 ms |
5224 KB |
Output is correct |
44 |
Correct |
346 ms |
5224 KB |
Output is correct |
45 |
Correct |
349 ms |
5224 KB |
Output is correct |
46 |
Correct |
419 ms |
4952 KB |
Output is correct |
47 |
Correct |
369 ms |
5092 KB |
Output is correct |
48 |
Correct |
416 ms |
5224 KB |
Output is correct |
49 |
Correct |
356 ms |
5092 KB |
Output is correct |
50 |
Correct |
326 ms |
5092 KB |
Output is correct |
51 |
Correct |
73 ms |
4952 KB |
Output is correct |
52 |
Correct |
403 ms |
5224 KB |
Output is correct |
53 |
Correct |
506 ms |
5224 KB |
Output is correct |
54 |
Correct |
493 ms |
5224 KB |
Output is correct |
55 |
Correct |
526 ms |
5420 KB |
Output is correct |
56 |
Correct |
396 ms |
5224 KB |
Output is correct |
57 |
Correct |
443 ms |
5420 KB |
Output is correct |
58 |
Correct |
429 ms |
5224 KB |
Output is correct |
59 |
Correct |
509 ms |
5420 KB |
Output is correct |
60 |
Correct |
119 ms |
4952 KB |
Output is correct |
61 |
Correct |
496 ms |
5420 KB |
Output is correct |
62 |
Correct |
419 ms |
5420 KB |
Output is correct |
63 |
Correct |
403 ms |
5420 KB |
Output is correct |
64 |
Correct |
406 ms |
5420 KB |
Output is correct |
65 |
Correct |
389 ms |
4952 KB |
Output is correct |
66 |
Correct |
406 ms |
5092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4952 KB |
Output is correct |
2 |
Correct |
16 ms |
4952 KB |
Output is correct |
3 |
Correct |
0 ms |
4952 KB |
Output is correct |
4 |
Correct |
6 ms |
4952 KB |
Output is correct |
5 |
Correct |
23 ms |
4952 KB |
Output is correct |
6 |
Correct |
16 ms |
4952 KB |
Output is correct |
7 |
Correct |
9 ms |
4952 KB |
Output is correct |
8 |
Correct |
16 ms |
4952 KB |
Output is correct |
9 |
Correct |
19 ms |
4952 KB |
Output is correct |
10 |
Correct |
53 ms |
4952 KB |
Output is correct |
11 |
Correct |
43 ms |
4952 KB |
Output is correct |
12 |
Correct |
53 ms |
4952 KB |
Output is correct |
13 |
Correct |
36 ms |
4952 KB |
Output is correct |
14 |
Correct |
49 ms |
4952 KB |
Output is correct |
15 |
Correct |
63 ms |
4952 KB |
Output is correct |
16 |
Correct |
49 ms |
4952 KB |
Output is correct |
17 |
Correct |
29 ms |
4952 KB |
Output is correct |
18 |
Correct |
49 ms |
4952 KB |
Output is correct |
19 |
Correct |
36 ms |
4952 KB |
Output is correct |
20 |
Correct |
46 ms |
4952 KB |
Output is correct |
21 |
Correct |
96 ms |
4952 KB |
Output is correct |
22 |
Correct |
113 ms |
4952 KB |
Output is correct |
23 |
Correct |
73 ms |
4952 KB |
Output is correct |
24 |
Correct |
163 ms |
4952 KB |
Output is correct |
25 |
Correct |
133 ms |
4952 KB |
Output is correct |
26 |
Correct |
156 ms |
4952 KB |
Output is correct |
27 |
Correct |
123 ms |
4952 KB |
Output is correct |
28 |
Correct |
133 ms |
4952 KB |
Output is correct |
29 |
Correct |
106 ms |
4952 KB |
Output is correct |
30 |
Correct |
119 ms |
4952 KB |
Output is correct |
31 |
Correct |
156 ms |
4952 KB |
Output is correct |
32 |
Correct |
129 ms |
4952 KB |
Output is correct |
33 |
Correct |
136 ms |
4952 KB |
Output is correct |
34 |
Correct |
169 ms |
4952 KB |
Output is correct |
35 |
Correct |
126 ms |
4952 KB |
Output is correct |
36 |
Correct |
153 ms |
4952 KB |
Output is correct |
37 |
Correct |
269 ms |
5092 KB |
Output is correct |
38 |
Correct |
313 ms |
5092 KB |
Output is correct |
39 |
Correct |
346 ms |
4952 KB |
Output is correct |
40 |
Correct |
453 ms |
5092 KB |
Output is correct |
41 |
Correct |
439 ms |
4952 KB |
Output is correct |
42 |
Correct |
386 ms |
5092 KB |
Output is correct |
43 |
Correct |
313 ms |
5224 KB |
Output is correct |
44 |
Correct |
346 ms |
5224 KB |
Output is correct |
45 |
Correct |
349 ms |
5224 KB |
Output is correct |
46 |
Correct |
419 ms |
4952 KB |
Output is correct |
47 |
Correct |
369 ms |
5092 KB |
Output is correct |
48 |
Correct |
416 ms |
5224 KB |
Output is correct |
49 |
Correct |
356 ms |
5092 KB |
Output is correct |
50 |
Correct |
326 ms |
5092 KB |
Output is correct |
51 |
Correct |
73 ms |
4952 KB |
Output is correct |
52 |
Correct |
403 ms |
5224 KB |
Output is correct |
53 |
Correct |
506 ms |
5224 KB |
Output is correct |
54 |
Correct |
493 ms |
5224 KB |
Output is correct |
55 |
Correct |
526 ms |
5420 KB |
Output is correct |
56 |
Correct |
396 ms |
5224 KB |
Output is correct |
57 |
Correct |
443 ms |
5420 KB |
Output is correct |
58 |
Correct |
429 ms |
5224 KB |
Output is correct |
59 |
Correct |
509 ms |
5420 KB |
Output is correct |
60 |
Correct |
119 ms |
4952 KB |
Output is correct |
61 |
Correct |
496 ms |
5420 KB |
Output is correct |
62 |
Correct |
419 ms |
5420 KB |
Output is correct |
63 |
Correct |
403 ms |
5420 KB |
Output is correct |
64 |
Correct |
406 ms |
5420 KB |
Output is correct |
65 |
Correct |
389 ms |
4952 KB |
Output is correct |
66 |
Correct |
406 ms |
5092 KB |
Output is correct |
67 |
Correct |
456 ms |
5420 KB |
Output is correct |
68 |
Correct |
129 ms |
4952 KB |
Output is correct |
69 |
Correct |
546 ms |
5804 KB |
Output is correct |
70 |
Correct |
626 ms |
5420 KB |
Output is correct |
71 |
Correct |
549 ms |
5420 KB |
Output is correct |
72 |
Correct |
609 ms |
4952 KB |
Output is correct |
73 |
Correct |
639 ms |
4952 KB |
Output is correct |
74 |
Correct |
539 ms |
5804 KB |
Output is correct |
75 |
Correct |
579 ms |
5804 KB |
Output is correct |
76 |
Correct |
526 ms |
5804 KB |
Output is correct |
77 |
Correct |
556 ms |
5804 KB |
Output is correct |