#include <bits/stdc++.h>
using namespace std;
#define sz(s) (int)s.size()
#define ll long long
#define ff first
#define ss second
const int N = 2e3 + 5;
const ll M = 1e9+7;
int n, a[N];
int main(){
cin >> n;
int mx = 0;
ll s = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
s += a[i];
mx = max(a[i],mx);
}
vector <vector<int>> dp(n+1, vector <int> (mx*n+1,0));
vector <int> v;
for(int i = 1; i <= n; i++){
v.clear();
for(int j = 1; j <= n; j++){
if(j == i) continue;
v.push_back(a[j]);
}
dp[i][0] = 1;
for(int j = 0; j < sz(v); j++){
for(int k = mx*n-v[j]; k >= 0; k--){
if(dp[i][k] == 1) dp[i][k+v[j]] = 1;
}
}
}
if(!dp[1][s/2] or s % 2 == 1){
cout << 0;
return 0;
}
v.clear();
for(int i = (a[1] % 2 == 0 ? 2 : 1); i <= n*mx; i += 2){
bool tr = 0;
for(int j = 1; j <= n; j++){
ll x = s-a[j]+i;
if(!dp[j][x/2] or x % 2 == 1){
tr = 1;
break;
}
}
if(tr == 0) v.push_back(i);
}
cout << sz(v) << '\n';
for(int i : v){
cout << i << ' ';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
508 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
508 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
444 KB |
Output is correct |
21 |
Correct |
19 ms |
1876 KB |
Output is correct |
22 |
Correct |
28 ms |
2792 KB |
Output is correct |
23 |
Correct |
9 ms |
1416 KB |
Output is correct |
24 |
Correct |
57 ms |
3932 KB |
Output is correct |
25 |
Correct |
69 ms |
3924 KB |
Output is correct |
26 |
Correct |
73 ms |
4180 KB |
Output is correct |
27 |
Correct |
82 ms |
4348 KB |
Output is correct |
28 |
Correct |
78 ms |
4180 KB |
Output is correct |
29 |
Correct |
74 ms |
4180 KB |
Output is correct |
30 |
Correct |
68 ms |
4180 KB |
Output is correct |
31 |
Correct |
68 ms |
4180 KB |
Output is correct |
32 |
Correct |
70 ms |
4180 KB |
Output is correct |
33 |
Correct |
72 ms |
4180 KB |
Output is correct |
34 |
Correct |
72 ms |
4180 KB |
Output is correct |
35 |
Correct |
74 ms |
4180 KB |
Output is correct |
36 |
Correct |
88 ms |
4392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
508 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
444 KB |
Output is correct |
21 |
Correct |
19 ms |
1876 KB |
Output is correct |
22 |
Correct |
28 ms |
2792 KB |
Output is correct |
23 |
Correct |
9 ms |
1416 KB |
Output is correct |
24 |
Correct |
57 ms |
3932 KB |
Output is correct |
25 |
Correct |
69 ms |
3924 KB |
Output is correct |
26 |
Correct |
73 ms |
4180 KB |
Output is correct |
27 |
Correct |
82 ms |
4348 KB |
Output is correct |
28 |
Correct |
78 ms |
4180 KB |
Output is correct |
29 |
Correct |
74 ms |
4180 KB |
Output is correct |
30 |
Correct |
68 ms |
4180 KB |
Output is correct |
31 |
Correct |
68 ms |
4180 KB |
Output is correct |
32 |
Correct |
70 ms |
4180 KB |
Output is correct |
33 |
Correct |
72 ms |
4180 KB |
Output is correct |
34 |
Correct |
72 ms |
4180 KB |
Output is correct |
35 |
Correct |
74 ms |
4180 KB |
Output is correct |
36 |
Correct |
88 ms |
4392 KB |
Output is correct |
37 |
Correct |
816 ms |
23996 KB |
Output is correct |
38 |
Correct |
850 ms |
23996 KB |
Output is correct |
39 |
Execution timed out |
1071 ms |
61520 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
508 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
444 KB |
Output is correct |
21 |
Correct |
19 ms |
1876 KB |
Output is correct |
22 |
Correct |
28 ms |
2792 KB |
Output is correct |
23 |
Correct |
9 ms |
1416 KB |
Output is correct |
24 |
Correct |
57 ms |
3932 KB |
Output is correct |
25 |
Correct |
69 ms |
3924 KB |
Output is correct |
26 |
Correct |
73 ms |
4180 KB |
Output is correct |
27 |
Correct |
82 ms |
4348 KB |
Output is correct |
28 |
Correct |
78 ms |
4180 KB |
Output is correct |
29 |
Correct |
74 ms |
4180 KB |
Output is correct |
30 |
Correct |
68 ms |
4180 KB |
Output is correct |
31 |
Correct |
68 ms |
4180 KB |
Output is correct |
32 |
Correct |
70 ms |
4180 KB |
Output is correct |
33 |
Correct |
72 ms |
4180 KB |
Output is correct |
34 |
Correct |
72 ms |
4180 KB |
Output is correct |
35 |
Correct |
74 ms |
4180 KB |
Output is correct |
36 |
Correct |
88 ms |
4392 KB |
Output is correct |
37 |
Correct |
816 ms |
23996 KB |
Output is correct |
38 |
Correct |
850 ms |
23996 KB |
Output is correct |
39 |
Execution timed out |
1071 ms |
61520 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
472 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
504 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
508 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
444 KB |
Output is correct |
21 |
Correct |
19 ms |
1876 KB |
Output is correct |
22 |
Correct |
28 ms |
2792 KB |
Output is correct |
23 |
Correct |
9 ms |
1416 KB |
Output is correct |
24 |
Correct |
57 ms |
3932 KB |
Output is correct |
25 |
Correct |
69 ms |
3924 KB |
Output is correct |
26 |
Correct |
73 ms |
4180 KB |
Output is correct |
27 |
Correct |
82 ms |
4348 KB |
Output is correct |
28 |
Correct |
78 ms |
4180 KB |
Output is correct |
29 |
Correct |
74 ms |
4180 KB |
Output is correct |
30 |
Correct |
68 ms |
4180 KB |
Output is correct |
31 |
Correct |
68 ms |
4180 KB |
Output is correct |
32 |
Correct |
70 ms |
4180 KB |
Output is correct |
33 |
Correct |
72 ms |
4180 KB |
Output is correct |
34 |
Correct |
72 ms |
4180 KB |
Output is correct |
35 |
Correct |
74 ms |
4180 KB |
Output is correct |
36 |
Correct |
88 ms |
4392 KB |
Output is correct |
37 |
Correct |
816 ms |
23996 KB |
Output is correct |
38 |
Correct |
850 ms |
23996 KB |
Output is correct |
39 |
Execution timed out |
1071 ms |
61520 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |