#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;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int n;
cin >> n;
int a[n+1], suma = 0;
for (int i = 1; i <= n; ++i){
cin >> a[i];
suma += a[i];
}
vi s(suma+10, INT32_MAX);
s[0] = 0;
for (int i = 1; i <= n; ++i){
for (int j = 0; j <= suma; ++j){
if (s[j] < i){
s[a[i]+j] = min(s[a[i]+j], i);
}
}
}
if (suma%2 || s[suma/2] == INT32_MAX)
return cout << "0\n", 0;
vi sol(suma+10, 1), moze(suma+10);
for (int k = 1; k <= n; ++k){
fill(s.begin(), s.end(), INT32_MAX);
s[0] = 0;
for (int i = 1; i <= n; ++i){
if (i == k) continue;
for (int j = 0; j <= suma; ++j){
if (s[j] < i){
int y = suma - a[k] - 2 * j;
if (y > 0)
moze[y] = k;
s[a[i]+j] = min(s[a[i]+j], i);
int x = suma - a[k] - 2 * (a[i] + j);
if (x > 0)
moze[x]=k;
}
}
}
for (int i = 1; i < suma; ++i){
if (moze[i]!=k || !sol[i])
sol[i ] = 0;
}
}
vi res;
for (int i = 1; i < suma; ++i)
if (sol[i])
res.push_back(i);
cout << (int)res.size() << '\n';
for (auto& i : res)
cout << i << ' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
68 ms |
364 KB |
Output is correct |
22 |
Correct |
108 ms |
432 KB |
Output is correct |
23 |
Correct |
31 ms |
364 KB |
Output is correct |
24 |
Correct |
221 ms |
492 KB |
Output is correct |
25 |
Correct |
273 ms |
492 KB |
Output is correct |
26 |
Correct |
341 ms |
504 KB |
Output is correct |
27 |
Correct |
240 ms |
492 KB |
Output is correct |
28 |
Correct |
211 ms |
492 KB |
Output is correct |
29 |
Correct |
232 ms |
492 KB |
Output is correct |
30 |
Correct |
289 ms |
364 KB |
Output is correct |
31 |
Correct |
397 ms |
492 KB |
Output is correct |
32 |
Correct |
266 ms |
492 KB |
Output is correct |
33 |
Correct |
105 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
213 ms |
492 KB |
Output is correct |
36 |
Correct |
257 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
68 ms |
364 KB |
Output is correct |
22 |
Correct |
108 ms |
432 KB |
Output is correct |
23 |
Correct |
31 ms |
364 KB |
Output is correct |
24 |
Correct |
221 ms |
492 KB |
Output is correct |
25 |
Correct |
273 ms |
492 KB |
Output is correct |
26 |
Correct |
341 ms |
504 KB |
Output is correct |
27 |
Correct |
240 ms |
492 KB |
Output is correct |
28 |
Correct |
211 ms |
492 KB |
Output is correct |
29 |
Correct |
232 ms |
492 KB |
Output is correct |
30 |
Correct |
289 ms |
364 KB |
Output is correct |
31 |
Correct |
397 ms |
492 KB |
Output is correct |
32 |
Correct |
266 ms |
492 KB |
Output is correct |
33 |
Correct |
105 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
213 ms |
492 KB |
Output is correct |
36 |
Correct |
257 ms |
492 KB |
Output is correct |
37 |
Execution timed out |
1081 ms |
492 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
68 ms |
364 KB |
Output is correct |
22 |
Correct |
108 ms |
432 KB |
Output is correct |
23 |
Correct |
31 ms |
364 KB |
Output is correct |
24 |
Correct |
221 ms |
492 KB |
Output is correct |
25 |
Correct |
273 ms |
492 KB |
Output is correct |
26 |
Correct |
341 ms |
504 KB |
Output is correct |
27 |
Correct |
240 ms |
492 KB |
Output is correct |
28 |
Correct |
211 ms |
492 KB |
Output is correct |
29 |
Correct |
232 ms |
492 KB |
Output is correct |
30 |
Correct |
289 ms |
364 KB |
Output is correct |
31 |
Correct |
397 ms |
492 KB |
Output is correct |
32 |
Correct |
266 ms |
492 KB |
Output is correct |
33 |
Correct |
105 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
213 ms |
492 KB |
Output is correct |
36 |
Correct |
257 ms |
492 KB |
Output is correct |
37 |
Execution timed out |
1081 ms |
492 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
2 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
68 ms |
364 KB |
Output is correct |
22 |
Correct |
108 ms |
432 KB |
Output is correct |
23 |
Correct |
31 ms |
364 KB |
Output is correct |
24 |
Correct |
221 ms |
492 KB |
Output is correct |
25 |
Correct |
273 ms |
492 KB |
Output is correct |
26 |
Correct |
341 ms |
504 KB |
Output is correct |
27 |
Correct |
240 ms |
492 KB |
Output is correct |
28 |
Correct |
211 ms |
492 KB |
Output is correct |
29 |
Correct |
232 ms |
492 KB |
Output is correct |
30 |
Correct |
289 ms |
364 KB |
Output is correct |
31 |
Correct |
397 ms |
492 KB |
Output is correct |
32 |
Correct |
266 ms |
492 KB |
Output is correct |
33 |
Correct |
105 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
213 ms |
492 KB |
Output is correct |
36 |
Correct |
257 ms |
492 KB |
Output is correct |
37 |
Execution timed out |
1081 ms |
492 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |