#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
int n;
int a[510];
ll dp[250010];
int sum;
void add(int x) {
sum += x;
for(int i = sum; i >= x; --i)
dp[i] += dp[i - x];
}
void del(int x) {
for(int i = x; i <= sum; ++i)
dp[i] -= dp[i - x];
sum -= x;
}
int go(int x) {
memset(dp, 0, sizeof(dp));
sum = 0;
dp[0] = 1;
a[n + 1] = x;
for(int i = 1; i <= n + 1; ++i)
add(a[i]);
for(int i = 1; i <= n + 1; ++i) {
del(a[i]);
if(sum & 1 || !dp[sum / 2])
return 0;
add(a[i]);
}
return 1;
}
void solve() {
cin >> n;
int s = 0;
for(int i = 1; i <= n; ++i) cin >> a[i], s += a[i];
veci ans;
for(int k = 1; k <= s; ++k)
if(go(k))
ans.pb(k);
cout << sz(ans) << '\n';
for(auto it : ans) cout << it << ' ';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
///cin >> T;
while(T--) solve(), cout << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
5 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
57 ms |
2284 KB |
Output is correct |
5 |
Correct |
71 ms |
2412 KB |
Output is correct |
6 |
Correct |
15 ms |
2284 KB |
Output is correct |
7 |
Correct |
24 ms |
2412 KB |
Output is correct |
8 |
Correct |
127 ms |
2284 KB |
Output is correct |
9 |
Correct |
41 ms |
2412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
5 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
57 ms |
2284 KB |
Output is correct |
5 |
Correct |
71 ms |
2412 KB |
Output is correct |
6 |
Correct |
15 ms |
2284 KB |
Output is correct |
7 |
Correct |
24 ms |
2412 KB |
Output is correct |
8 |
Correct |
127 ms |
2284 KB |
Output is correct |
9 |
Correct |
41 ms |
2412 KB |
Output is correct |
10 |
Correct |
44 ms |
2284 KB |
Output is correct |
11 |
Correct |
21 ms |
2284 KB |
Output is correct |
12 |
Correct |
29 ms |
2284 KB |
Output is correct |
13 |
Correct |
19 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2284 KB |
Output is correct |
15 |
Correct |
18 ms |
2284 KB |
Output is correct |
16 |
Correct |
21 ms |
2284 KB |
Output is correct |
17 |
Correct |
15 ms |
2284 KB |
Output is correct |
18 |
Correct |
20 ms |
2284 KB |
Output is correct |
19 |
Correct |
16 ms |
2284 KB |
Output is correct |
20 |
Correct |
46 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
5 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
57 ms |
2284 KB |
Output is correct |
5 |
Correct |
71 ms |
2412 KB |
Output is correct |
6 |
Correct |
15 ms |
2284 KB |
Output is correct |
7 |
Correct |
24 ms |
2412 KB |
Output is correct |
8 |
Correct |
127 ms |
2284 KB |
Output is correct |
9 |
Correct |
41 ms |
2412 KB |
Output is correct |
10 |
Correct |
44 ms |
2284 KB |
Output is correct |
11 |
Correct |
21 ms |
2284 KB |
Output is correct |
12 |
Correct |
29 ms |
2284 KB |
Output is correct |
13 |
Correct |
19 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2284 KB |
Output is correct |
15 |
Correct |
18 ms |
2284 KB |
Output is correct |
16 |
Correct |
21 ms |
2284 KB |
Output is correct |
17 |
Correct |
15 ms |
2284 KB |
Output is correct |
18 |
Correct |
20 ms |
2284 KB |
Output is correct |
19 |
Correct |
16 ms |
2284 KB |
Output is correct |
20 |
Correct |
46 ms |
2284 KB |
Output is correct |
21 |
Correct |
912 ms |
2412 KB |
Output is correct |
22 |
Execution timed out |
1094 ms |
2412 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
5 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
57 ms |
2284 KB |
Output is correct |
5 |
Correct |
71 ms |
2412 KB |
Output is correct |
6 |
Correct |
15 ms |
2284 KB |
Output is correct |
7 |
Correct |
24 ms |
2412 KB |
Output is correct |
8 |
Correct |
127 ms |
2284 KB |
Output is correct |
9 |
Correct |
41 ms |
2412 KB |
Output is correct |
10 |
Correct |
44 ms |
2284 KB |
Output is correct |
11 |
Correct |
21 ms |
2284 KB |
Output is correct |
12 |
Correct |
29 ms |
2284 KB |
Output is correct |
13 |
Correct |
19 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2284 KB |
Output is correct |
15 |
Correct |
18 ms |
2284 KB |
Output is correct |
16 |
Correct |
21 ms |
2284 KB |
Output is correct |
17 |
Correct |
15 ms |
2284 KB |
Output is correct |
18 |
Correct |
20 ms |
2284 KB |
Output is correct |
19 |
Correct |
16 ms |
2284 KB |
Output is correct |
20 |
Correct |
46 ms |
2284 KB |
Output is correct |
21 |
Correct |
912 ms |
2412 KB |
Output is correct |
22 |
Execution timed out |
1094 ms |
2412 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
5 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
57 ms |
2284 KB |
Output is correct |
5 |
Correct |
71 ms |
2412 KB |
Output is correct |
6 |
Correct |
15 ms |
2284 KB |
Output is correct |
7 |
Correct |
24 ms |
2412 KB |
Output is correct |
8 |
Correct |
127 ms |
2284 KB |
Output is correct |
9 |
Correct |
41 ms |
2412 KB |
Output is correct |
10 |
Correct |
44 ms |
2284 KB |
Output is correct |
11 |
Correct |
21 ms |
2284 KB |
Output is correct |
12 |
Correct |
29 ms |
2284 KB |
Output is correct |
13 |
Correct |
19 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2284 KB |
Output is correct |
15 |
Correct |
18 ms |
2284 KB |
Output is correct |
16 |
Correct |
21 ms |
2284 KB |
Output is correct |
17 |
Correct |
15 ms |
2284 KB |
Output is correct |
18 |
Correct |
20 ms |
2284 KB |
Output is correct |
19 |
Correct |
16 ms |
2284 KB |
Output is correct |
20 |
Correct |
46 ms |
2284 KB |
Output is correct |
21 |
Correct |
912 ms |
2412 KB |
Output is correct |
22 |
Execution timed out |
1094 ms |
2412 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2284 KB |
Output is correct |
2 |
Correct |
5 ms |
2284 KB |
Output is correct |
3 |
Correct |
2 ms |
2284 KB |
Output is correct |
4 |
Correct |
57 ms |
2284 KB |
Output is correct |
5 |
Correct |
71 ms |
2412 KB |
Output is correct |
6 |
Correct |
15 ms |
2284 KB |
Output is correct |
7 |
Correct |
24 ms |
2412 KB |
Output is correct |
8 |
Correct |
127 ms |
2284 KB |
Output is correct |
9 |
Correct |
41 ms |
2412 KB |
Output is correct |
10 |
Correct |
44 ms |
2284 KB |
Output is correct |
11 |
Correct |
21 ms |
2284 KB |
Output is correct |
12 |
Correct |
29 ms |
2284 KB |
Output is correct |
13 |
Correct |
19 ms |
2284 KB |
Output is correct |
14 |
Correct |
24 ms |
2284 KB |
Output is correct |
15 |
Correct |
18 ms |
2284 KB |
Output is correct |
16 |
Correct |
21 ms |
2284 KB |
Output is correct |
17 |
Correct |
15 ms |
2284 KB |
Output is correct |
18 |
Correct |
20 ms |
2284 KB |
Output is correct |
19 |
Correct |
16 ms |
2284 KB |
Output is correct |
20 |
Correct |
46 ms |
2284 KB |
Output is correct |
21 |
Correct |
912 ms |
2412 KB |
Output is correct |
22 |
Execution timed out |
1094 ms |
2412 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |