#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
#define ld long double
using namespace std;
const ll N = 350 + 1;
const ll M = 1e4 + 10;
const ll big = 1e17;
const ll hsh2 = 1964325029;
const long long mod = 1e9 + 7;
const long double EPS = 1e-10;
const ll block = 1e7;
const ll shift = 2e3;
const ld pi = acos(-1.0);
ll sum = 0;
ll n;
ll a[N];
ll dp[N * N];
void add(ll x) {
for(int i = sum + x; i >= x; i--)
dp[i] += dp[i - x];
sum += x;
}
void del(ll x) {
for(int i = 0; i <= sum - x; i++)
dp[i + x] -= dp[i];
sum -= x;
}
bitset<N * N> x, ans, tr;
int main() {
speed;
cin >> n;
dp[0] = 1ll;
for(int i = 1; i <= n; i++)
cin >> a[i], add(a[i]);
for(int i = 1; i <= sum; i++)
ans[i] = 1;
if(sum % 2 != 0 || !dp[sum/2])
cout << 0, ex;
for(int i = 1; i <= n; i++) {
tr = 0;
ll sum2 = sum - a[i];
del(a[i]);
for(int j = 1; j <= sum2; j++) {
if(dp[j]) {
ll p = sum2 - j;
ll z = j - p;
if(z <= 0)continue;
tr[z] = 1;
}
}
add(a[i]);
ans &= tr;
}
vector<int> answ;
for(int i = 1; i <= sum ; i++)
if(ans[i])
answ.pb(i);
cout << answ.size() << '\n';
for(auto u : answ)
cout << u << " ";
cout << '\n';
}
/*
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
3 ms |
332 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
5 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
460 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
3 ms |
332 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
3 ms |
332 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
5 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
460 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
3 ms |
332 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
332 KB |
Output is correct |
37 |
Correct |
14 ms |
644 KB |
Output is correct |
38 |
Correct |
15 ms |
644 KB |
Output is correct |
39 |
Correct |
43 ms |
828 KB |
Output is correct |
40 |
Correct |
34 ms |
728 KB |
Output is correct |
41 |
Correct |
55 ms |
912 KB |
Output is correct |
42 |
Correct |
25 ms |
716 KB |
Output is correct |
43 |
Correct |
48 ms |
1160 KB |
Output is correct |
44 |
Correct |
48 ms |
1164 KB |
Output is correct |
45 |
Correct |
47 ms |
1056 KB |
Output is correct |
46 |
Correct |
24 ms |
708 KB |
Output is correct |
47 |
Correct |
28 ms |
808 KB |
Output is correct |
48 |
Correct |
49 ms |
1088 KB |
Output is correct |
49 |
Correct |
57 ms |
824 KB |
Output is correct |
50 |
Correct |
28 ms |
724 KB |
Output is correct |
51 |
Correct |
3 ms |
460 KB |
Output is correct |
52 |
Correct |
64 ms |
1288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
3 ms |
332 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
5 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
460 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
3 ms |
332 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
332 KB |
Output is correct |
37 |
Correct |
14 ms |
644 KB |
Output is correct |
38 |
Correct |
15 ms |
644 KB |
Output is correct |
39 |
Correct |
43 ms |
828 KB |
Output is correct |
40 |
Correct |
34 ms |
728 KB |
Output is correct |
41 |
Correct |
55 ms |
912 KB |
Output is correct |
42 |
Correct |
25 ms |
716 KB |
Output is correct |
43 |
Correct |
48 ms |
1160 KB |
Output is correct |
44 |
Correct |
48 ms |
1164 KB |
Output is correct |
45 |
Correct |
47 ms |
1056 KB |
Output is correct |
46 |
Correct |
24 ms |
708 KB |
Output is correct |
47 |
Correct |
28 ms |
808 KB |
Output is correct |
48 |
Correct |
49 ms |
1088 KB |
Output is correct |
49 |
Correct |
57 ms |
824 KB |
Output is correct |
50 |
Correct |
28 ms |
724 KB |
Output is correct |
51 |
Correct |
3 ms |
460 KB |
Output is correct |
52 |
Correct |
64 ms |
1288 KB |
Output is correct |
53 |
Correct |
46 ms |
964 KB |
Output is correct |
54 |
Correct |
64 ms |
1080 KB |
Output is correct |
55 |
Correct |
148 ms |
1728 KB |
Output is correct |
56 |
Correct |
57 ms |
1172 KB |
Output is correct |
57 |
Correct |
130 ms |
1864 KB |
Output is correct |
58 |
Correct |
71 ms |
1208 KB |
Output is correct |
59 |
Correct |
88 ms |
1324 KB |
Output is correct |
60 |
Correct |
9 ms |
716 KB |
Output is correct |
61 |
Correct |
98 ms |
1540 KB |
Output is correct |
62 |
Correct |
101 ms |
1624 KB |
Output is correct |
63 |
Correct |
111 ms |
1804 KB |
Output is correct |
64 |
Correct |
114 ms |
1668 KB |
Output is correct |
65 |
Correct |
60 ms |
728 KB |
Output is correct |
66 |
Correct |
45 ms |
776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
3 ms |
332 KB |
Output is correct |
25 |
Correct |
4 ms |
460 KB |
Output is correct |
26 |
Correct |
5 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
460 KB |
Output is correct |
29 |
Correct |
4 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
4 ms |
460 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
332 KB |
Output is correct |
34 |
Correct |
3 ms |
332 KB |
Output is correct |
35 |
Correct |
4 ms |
332 KB |
Output is correct |
36 |
Correct |
3 ms |
332 KB |
Output is correct |
37 |
Correct |
14 ms |
644 KB |
Output is correct |
38 |
Correct |
15 ms |
644 KB |
Output is correct |
39 |
Correct |
43 ms |
828 KB |
Output is correct |
40 |
Correct |
34 ms |
728 KB |
Output is correct |
41 |
Correct |
55 ms |
912 KB |
Output is correct |
42 |
Correct |
25 ms |
716 KB |
Output is correct |
43 |
Correct |
48 ms |
1160 KB |
Output is correct |
44 |
Correct |
48 ms |
1164 KB |
Output is correct |
45 |
Correct |
47 ms |
1056 KB |
Output is correct |
46 |
Correct |
24 ms |
708 KB |
Output is correct |
47 |
Correct |
28 ms |
808 KB |
Output is correct |
48 |
Correct |
49 ms |
1088 KB |
Output is correct |
49 |
Correct |
57 ms |
824 KB |
Output is correct |
50 |
Correct |
28 ms |
724 KB |
Output is correct |
51 |
Correct |
3 ms |
460 KB |
Output is correct |
52 |
Correct |
64 ms |
1288 KB |
Output is correct |
53 |
Correct |
46 ms |
964 KB |
Output is correct |
54 |
Correct |
64 ms |
1080 KB |
Output is correct |
55 |
Correct |
148 ms |
1728 KB |
Output is correct |
56 |
Correct |
57 ms |
1172 KB |
Output is correct |
57 |
Correct |
130 ms |
1864 KB |
Output is correct |
58 |
Correct |
71 ms |
1208 KB |
Output is correct |
59 |
Correct |
88 ms |
1324 KB |
Output is correct |
60 |
Correct |
9 ms |
716 KB |
Output is correct |
61 |
Correct |
98 ms |
1540 KB |
Output is correct |
62 |
Correct |
101 ms |
1624 KB |
Output is correct |
63 |
Correct |
111 ms |
1804 KB |
Output is correct |
64 |
Correct |
114 ms |
1668 KB |
Output is correct |
65 |
Correct |
60 ms |
728 KB |
Output is correct |
66 |
Correct |
45 ms |
776 KB |
Output is correct |
67 |
Incorrect |
5 ms |
716 KB |
Output isn't correct |
68 |
Halted |
0 ms |
0 KB |
- |