#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;
void no(){
cout << "0\n";
exit(0);
}
const int M = (501 * 500) /2 + 500;
int d[M+505], dp[M+505], a[M+505], cnt[M+505];
vi sol;
int main()
{
int n;
cin >> n;
int suma = 0;
for (int i = 0; i < n; ++i){
cin >> a[i];
suma += a[i];
}
if (suma%2) no();
dp[0]=1;
for (int i = 0; i < n; ++i){
for (int j = M; j > -1; --j){
dp[a[i]+j] += dp[j];
}
}
if (!dp[suma/2]) no();
for (int i = 0; i < n; ++i){
memset(d, 0, sizeof(d));
for (int j = 0; j <= M; ++j){
d[j] += dp[j];
d[j+a[i]] -= d[j];
}
for (int j = 0; j <= M; ++j){
if ((suma-a[i]+j)%2 == 0 && suma-a[i]-j>=0 && d[(suma-a[i]-j)/2]){
++cnt[j];
}
}
}
for (int i = 1; i <= M; ++i)
if (cnt[i] == n)
sol.push_back(i);
cout << (int)sol.size() << '\n';
for (auto& i : sol)
cout << i << ' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
Output is correct |
2 |
Correct |
4 ms |
1260 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
1260 KB |
Output is correct |
5 |
Correct |
6 ms |
1260 KB |
Output is correct |
6 |
Correct |
4 ms |
1260 KB |
Output is correct |
7 |
Correct |
4 ms |
1260 KB |
Output is correct |
8 |
Correct |
6 ms |
1260 KB |
Output is correct |
9 |
Correct |
5 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
Output is correct |
2 |
Correct |
4 ms |
1260 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
1260 KB |
Output is correct |
5 |
Correct |
6 ms |
1260 KB |
Output is correct |
6 |
Correct |
4 ms |
1260 KB |
Output is correct |
7 |
Correct |
4 ms |
1260 KB |
Output is correct |
8 |
Correct |
6 ms |
1260 KB |
Output is correct |
9 |
Correct |
5 ms |
1260 KB |
Output is correct |
10 |
Correct |
12 ms |
1260 KB |
Output is correct |
11 |
Correct |
13 ms |
1260 KB |
Output is correct |
12 |
Correct |
13 ms |
1260 KB |
Output is correct |
13 |
Correct |
13 ms |
1260 KB |
Output is correct |
14 |
Correct |
12 ms |
1260 KB |
Output is correct |
15 |
Correct |
13 ms |
1260 KB |
Output is correct |
16 |
Correct |
14 ms |
1260 KB |
Output is correct |
17 |
Correct |
8 ms |
1260 KB |
Output is correct |
18 |
Correct |
11 ms |
1260 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
13 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
Output is correct |
2 |
Correct |
4 ms |
1260 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
1260 KB |
Output is correct |
5 |
Correct |
6 ms |
1260 KB |
Output is correct |
6 |
Correct |
4 ms |
1260 KB |
Output is correct |
7 |
Correct |
4 ms |
1260 KB |
Output is correct |
8 |
Correct |
6 ms |
1260 KB |
Output is correct |
9 |
Correct |
5 ms |
1260 KB |
Output is correct |
10 |
Correct |
12 ms |
1260 KB |
Output is correct |
11 |
Correct |
13 ms |
1260 KB |
Output is correct |
12 |
Correct |
13 ms |
1260 KB |
Output is correct |
13 |
Correct |
13 ms |
1260 KB |
Output is correct |
14 |
Correct |
12 ms |
1260 KB |
Output is correct |
15 |
Correct |
13 ms |
1260 KB |
Output is correct |
16 |
Correct |
14 ms |
1260 KB |
Output is correct |
17 |
Correct |
8 ms |
1260 KB |
Output is correct |
18 |
Correct |
11 ms |
1260 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
13 ms |
1260 KB |
Output is correct |
21 |
Correct |
25 ms |
1388 KB |
Output is correct |
22 |
Correct |
29 ms |
1388 KB |
Output is correct |
23 |
Correct |
21 ms |
1388 KB |
Output is correct |
24 |
Correct |
38 ms |
1388 KB |
Output is correct |
25 |
Correct |
37 ms |
1388 KB |
Output is correct |
26 |
Correct |
39 ms |
1388 KB |
Output is correct |
27 |
Correct |
39 ms |
1388 KB |
Output is correct |
28 |
Correct |
38 ms |
1388 KB |
Output is correct |
29 |
Correct |
38 ms |
1388 KB |
Output is correct |
30 |
Correct |
38 ms |
1388 KB |
Output is correct |
31 |
Correct |
39 ms |
1388 KB |
Output is correct |
32 |
Correct |
39 ms |
1388 KB |
Output is correct |
33 |
Correct |
38 ms |
1388 KB |
Output is correct |
34 |
Correct |
40 ms |
1388 KB |
Output is correct |
35 |
Correct |
39 ms |
1388 KB |
Output is correct |
36 |
Correct |
45 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
Output is correct |
2 |
Correct |
4 ms |
1260 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
1260 KB |
Output is correct |
5 |
Correct |
6 ms |
1260 KB |
Output is correct |
6 |
Correct |
4 ms |
1260 KB |
Output is correct |
7 |
Correct |
4 ms |
1260 KB |
Output is correct |
8 |
Correct |
6 ms |
1260 KB |
Output is correct |
9 |
Correct |
5 ms |
1260 KB |
Output is correct |
10 |
Correct |
12 ms |
1260 KB |
Output is correct |
11 |
Correct |
13 ms |
1260 KB |
Output is correct |
12 |
Correct |
13 ms |
1260 KB |
Output is correct |
13 |
Correct |
13 ms |
1260 KB |
Output is correct |
14 |
Correct |
12 ms |
1260 KB |
Output is correct |
15 |
Correct |
13 ms |
1260 KB |
Output is correct |
16 |
Correct |
14 ms |
1260 KB |
Output is correct |
17 |
Correct |
8 ms |
1260 KB |
Output is correct |
18 |
Correct |
11 ms |
1260 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
13 ms |
1260 KB |
Output is correct |
21 |
Correct |
25 ms |
1388 KB |
Output is correct |
22 |
Correct |
29 ms |
1388 KB |
Output is correct |
23 |
Correct |
21 ms |
1388 KB |
Output is correct |
24 |
Correct |
38 ms |
1388 KB |
Output is correct |
25 |
Correct |
37 ms |
1388 KB |
Output is correct |
26 |
Correct |
39 ms |
1388 KB |
Output is correct |
27 |
Correct |
39 ms |
1388 KB |
Output is correct |
28 |
Correct |
38 ms |
1388 KB |
Output is correct |
29 |
Correct |
38 ms |
1388 KB |
Output is correct |
30 |
Correct |
38 ms |
1388 KB |
Output is correct |
31 |
Correct |
39 ms |
1388 KB |
Output is correct |
32 |
Correct |
39 ms |
1388 KB |
Output is correct |
33 |
Correct |
38 ms |
1388 KB |
Output is correct |
34 |
Correct |
40 ms |
1388 KB |
Output is correct |
35 |
Correct |
39 ms |
1388 KB |
Output is correct |
36 |
Correct |
45 ms |
1388 KB |
Output is correct |
37 |
Correct |
77 ms |
1516 KB |
Output is correct |
38 |
Correct |
76 ms |
1516 KB |
Output is correct |
39 |
Correct |
95 ms |
1644 KB |
Output is correct |
40 |
Correct |
106 ms |
1644 KB |
Output is correct |
41 |
Correct |
105 ms |
1644 KB |
Output is correct |
42 |
Correct |
96 ms |
1644 KB |
Output is correct |
43 |
Correct |
100 ms |
1900 KB |
Output is correct |
44 |
Correct |
99 ms |
1900 KB |
Output is correct |
45 |
Correct |
100 ms |
1900 KB |
Output is correct |
46 |
Correct |
105 ms |
1516 KB |
Output is correct |
47 |
Correct |
97 ms |
1644 KB |
Output is correct |
48 |
Correct |
100 ms |
1900 KB |
Output is correct |
49 |
Correct |
100 ms |
1644 KB |
Output is correct |
50 |
Correct |
96 ms |
1644 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
111 ms |
2028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
Output is correct |
2 |
Correct |
4 ms |
1260 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
1260 KB |
Output is correct |
5 |
Correct |
6 ms |
1260 KB |
Output is correct |
6 |
Correct |
4 ms |
1260 KB |
Output is correct |
7 |
Correct |
4 ms |
1260 KB |
Output is correct |
8 |
Correct |
6 ms |
1260 KB |
Output is correct |
9 |
Correct |
5 ms |
1260 KB |
Output is correct |
10 |
Correct |
12 ms |
1260 KB |
Output is correct |
11 |
Correct |
13 ms |
1260 KB |
Output is correct |
12 |
Correct |
13 ms |
1260 KB |
Output is correct |
13 |
Correct |
13 ms |
1260 KB |
Output is correct |
14 |
Correct |
12 ms |
1260 KB |
Output is correct |
15 |
Correct |
13 ms |
1260 KB |
Output is correct |
16 |
Correct |
14 ms |
1260 KB |
Output is correct |
17 |
Correct |
8 ms |
1260 KB |
Output is correct |
18 |
Correct |
11 ms |
1260 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
13 ms |
1260 KB |
Output is correct |
21 |
Correct |
25 ms |
1388 KB |
Output is correct |
22 |
Correct |
29 ms |
1388 KB |
Output is correct |
23 |
Correct |
21 ms |
1388 KB |
Output is correct |
24 |
Correct |
38 ms |
1388 KB |
Output is correct |
25 |
Correct |
37 ms |
1388 KB |
Output is correct |
26 |
Correct |
39 ms |
1388 KB |
Output is correct |
27 |
Correct |
39 ms |
1388 KB |
Output is correct |
28 |
Correct |
38 ms |
1388 KB |
Output is correct |
29 |
Correct |
38 ms |
1388 KB |
Output is correct |
30 |
Correct |
38 ms |
1388 KB |
Output is correct |
31 |
Correct |
39 ms |
1388 KB |
Output is correct |
32 |
Correct |
39 ms |
1388 KB |
Output is correct |
33 |
Correct |
38 ms |
1388 KB |
Output is correct |
34 |
Correct |
40 ms |
1388 KB |
Output is correct |
35 |
Correct |
39 ms |
1388 KB |
Output is correct |
36 |
Correct |
45 ms |
1388 KB |
Output is correct |
37 |
Correct |
77 ms |
1516 KB |
Output is correct |
38 |
Correct |
76 ms |
1516 KB |
Output is correct |
39 |
Correct |
95 ms |
1644 KB |
Output is correct |
40 |
Correct |
106 ms |
1644 KB |
Output is correct |
41 |
Correct |
105 ms |
1644 KB |
Output is correct |
42 |
Correct |
96 ms |
1644 KB |
Output is correct |
43 |
Correct |
100 ms |
1900 KB |
Output is correct |
44 |
Correct |
99 ms |
1900 KB |
Output is correct |
45 |
Correct |
100 ms |
1900 KB |
Output is correct |
46 |
Correct |
105 ms |
1516 KB |
Output is correct |
47 |
Correct |
97 ms |
1644 KB |
Output is correct |
48 |
Correct |
100 ms |
1900 KB |
Output is correct |
49 |
Correct |
100 ms |
1644 KB |
Output is correct |
50 |
Correct |
96 ms |
1644 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
111 ms |
2028 KB |
Output is correct |
53 |
Correct |
119 ms |
1792 KB |
Output is correct |
54 |
Correct |
149 ms |
1900 KB |
Output is correct |
55 |
Correct |
147 ms |
2408 KB |
Output is correct |
56 |
Correct |
121 ms |
2028 KB |
Output is correct |
57 |
Correct |
148 ms |
2408 KB |
Output is correct |
58 |
Correct |
138 ms |
2028 KB |
Output is correct |
59 |
Correct |
145 ms |
2048 KB |
Output is correct |
60 |
Correct |
1 ms |
364 KB |
Output is correct |
61 |
Correct |
145 ms |
2280 KB |
Output is correct |
62 |
Correct |
132 ms |
2280 KB |
Output is correct |
63 |
Correct |
134 ms |
2280 KB |
Output is correct |
64 |
Correct |
133 ms |
2280 KB |
Output is correct |
65 |
Correct |
124 ms |
1516 KB |
Output is correct |
66 |
Correct |
125 ms |
1644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1260 KB |
Output is correct |
2 |
Correct |
4 ms |
1260 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
1260 KB |
Output is correct |
5 |
Correct |
6 ms |
1260 KB |
Output is correct |
6 |
Correct |
4 ms |
1260 KB |
Output is correct |
7 |
Correct |
4 ms |
1260 KB |
Output is correct |
8 |
Correct |
6 ms |
1260 KB |
Output is correct |
9 |
Correct |
5 ms |
1260 KB |
Output is correct |
10 |
Correct |
12 ms |
1260 KB |
Output is correct |
11 |
Correct |
13 ms |
1260 KB |
Output is correct |
12 |
Correct |
13 ms |
1260 KB |
Output is correct |
13 |
Correct |
13 ms |
1260 KB |
Output is correct |
14 |
Correct |
12 ms |
1260 KB |
Output is correct |
15 |
Correct |
13 ms |
1260 KB |
Output is correct |
16 |
Correct |
14 ms |
1260 KB |
Output is correct |
17 |
Correct |
8 ms |
1260 KB |
Output is correct |
18 |
Correct |
11 ms |
1260 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
13 ms |
1260 KB |
Output is correct |
21 |
Correct |
25 ms |
1388 KB |
Output is correct |
22 |
Correct |
29 ms |
1388 KB |
Output is correct |
23 |
Correct |
21 ms |
1388 KB |
Output is correct |
24 |
Correct |
38 ms |
1388 KB |
Output is correct |
25 |
Correct |
37 ms |
1388 KB |
Output is correct |
26 |
Correct |
39 ms |
1388 KB |
Output is correct |
27 |
Correct |
39 ms |
1388 KB |
Output is correct |
28 |
Correct |
38 ms |
1388 KB |
Output is correct |
29 |
Correct |
38 ms |
1388 KB |
Output is correct |
30 |
Correct |
38 ms |
1388 KB |
Output is correct |
31 |
Correct |
39 ms |
1388 KB |
Output is correct |
32 |
Correct |
39 ms |
1388 KB |
Output is correct |
33 |
Correct |
38 ms |
1388 KB |
Output is correct |
34 |
Correct |
40 ms |
1388 KB |
Output is correct |
35 |
Correct |
39 ms |
1388 KB |
Output is correct |
36 |
Correct |
45 ms |
1388 KB |
Output is correct |
37 |
Correct |
77 ms |
1516 KB |
Output is correct |
38 |
Correct |
76 ms |
1516 KB |
Output is correct |
39 |
Correct |
95 ms |
1644 KB |
Output is correct |
40 |
Correct |
106 ms |
1644 KB |
Output is correct |
41 |
Correct |
105 ms |
1644 KB |
Output is correct |
42 |
Correct |
96 ms |
1644 KB |
Output is correct |
43 |
Correct |
100 ms |
1900 KB |
Output is correct |
44 |
Correct |
99 ms |
1900 KB |
Output is correct |
45 |
Correct |
100 ms |
1900 KB |
Output is correct |
46 |
Correct |
105 ms |
1516 KB |
Output is correct |
47 |
Correct |
97 ms |
1644 KB |
Output is correct |
48 |
Correct |
100 ms |
1900 KB |
Output is correct |
49 |
Correct |
100 ms |
1644 KB |
Output is correct |
50 |
Correct |
96 ms |
1644 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
111 ms |
2028 KB |
Output is correct |
53 |
Correct |
119 ms |
1792 KB |
Output is correct |
54 |
Correct |
149 ms |
1900 KB |
Output is correct |
55 |
Correct |
147 ms |
2408 KB |
Output is correct |
56 |
Correct |
121 ms |
2028 KB |
Output is correct |
57 |
Correct |
148 ms |
2408 KB |
Output is correct |
58 |
Correct |
138 ms |
2028 KB |
Output is correct |
59 |
Correct |
145 ms |
2048 KB |
Output is correct |
60 |
Correct |
1 ms |
364 KB |
Output is correct |
61 |
Correct |
145 ms |
2280 KB |
Output is correct |
62 |
Correct |
132 ms |
2280 KB |
Output is correct |
63 |
Correct |
134 ms |
2280 KB |
Output is correct |
64 |
Correct |
133 ms |
2280 KB |
Output is correct |
65 |
Correct |
124 ms |
1516 KB |
Output is correct |
66 |
Correct |
125 ms |
1644 KB |
Output is correct |
67 |
Correct |
157 ms |
2152 KB |
Output is correct |
68 |
Correct |
33 ms |
876 KB |
Output is correct |
69 |
Incorrect |
208 ms |
2536 KB |
Output isn't correct |
70 |
Halted |
0 ms |
0 KB |
- |