//stupid solution 1
#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define forn(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ld = long double;
const int N = 500 + 7;
const int NN = N * N;
const ll mod = 1e9 + 7;
const ll inf = 2e18;
auto ra = [] {char *p = new char ; delete p ; return ll(p) ; };
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (ra() | 1));
int n;
bitset<NN> eval(vi v)
{
bitset<NN> ret;
ret[0] = 1;
for (auto u : v)
ret = (ret | (ret << u));
return ret;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("in.in", "r", stdin);
cin >> n;
vi a(n), ans;
int sum = 0;
for (auto &u : a)
cin >> u;
sum = accumulate(a.begin(), a.end(), 0);
bitset<NN> bs = eval(a);
if (sum & 1 || !bs[sum / 2])
return cout << 0, 0;
set<int> st;
map<int, int> ret;
for (int i = 0; i < n; ++i)
{
int x = a[i];
a[i] = 0;
bitset<NN> bts = eval(a);
int sm = sum - x;
for (int j = 0; j <= sm; ++j)
{
if (bts[j])
{
if (2 * j != sm)
ret[abs(j - (sm - j))]++;
}
}
a[i] = x;
}
int sz = 0;
for (auto u : ret)
if (u.second == 2 * n)
++sz;
cout << sz << "\n";
for (auto u : ret)
if (u.second == n * 2)
cout << u.first << " ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
52 ms |
492 KB |
Output is correct |
22 |
Correct |
68 ms |
492 KB |
Output is correct |
23 |
Correct |
33 ms |
492 KB |
Output is correct |
24 |
Correct |
111 ms |
624 KB |
Output is correct |
25 |
Correct |
127 ms |
748 KB |
Output is correct |
26 |
Correct |
147 ms |
620 KB |
Output is correct |
27 |
Correct |
131 ms |
620 KB |
Output is correct |
28 |
Correct |
119 ms |
620 KB |
Output is correct |
29 |
Correct |
140 ms |
620 KB |
Output is correct |
30 |
Correct |
131 ms |
764 KB |
Output is correct |
31 |
Correct |
141 ms |
748 KB |
Output is correct |
32 |
Correct |
124 ms |
620 KB |
Output is correct |
33 |
Correct |
103 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
122 ms |
620 KB |
Output is correct |
36 |
Correct |
125 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
52 ms |
492 KB |
Output is correct |
22 |
Correct |
68 ms |
492 KB |
Output is correct |
23 |
Correct |
33 ms |
492 KB |
Output is correct |
24 |
Correct |
111 ms |
624 KB |
Output is correct |
25 |
Correct |
127 ms |
748 KB |
Output is correct |
26 |
Correct |
147 ms |
620 KB |
Output is correct |
27 |
Correct |
131 ms |
620 KB |
Output is correct |
28 |
Correct |
119 ms |
620 KB |
Output is correct |
29 |
Correct |
140 ms |
620 KB |
Output is correct |
30 |
Correct |
131 ms |
764 KB |
Output is correct |
31 |
Correct |
141 ms |
748 KB |
Output is correct |
32 |
Correct |
124 ms |
620 KB |
Output is correct |
33 |
Correct |
103 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
122 ms |
620 KB |
Output is correct |
36 |
Correct |
125 ms |
748 KB |
Output is correct |
37 |
Correct |
673 ms |
1004 KB |
Output is correct |
38 |
Correct |
678 ms |
1132 KB |
Output is correct |
39 |
Correct |
638 ms |
520 KB |
Output is correct |
40 |
Execution timed out |
1061 ms |
1260 KB |
Time limit exceeded |
41 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
52 ms |
492 KB |
Output is correct |
22 |
Correct |
68 ms |
492 KB |
Output is correct |
23 |
Correct |
33 ms |
492 KB |
Output is correct |
24 |
Correct |
111 ms |
624 KB |
Output is correct |
25 |
Correct |
127 ms |
748 KB |
Output is correct |
26 |
Correct |
147 ms |
620 KB |
Output is correct |
27 |
Correct |
131 ms |
620 KB |
Output is correct |
28 |
Correct |
119 ms |
620 KB |
Output is correct |
29 |
Correct |
140 ms |
620 KB |
Output is correct |
30 |
Correct |
131 ms |
764 KB |
Output is correct |
31 |
Correct |
141 ms |
748 KB |
Output is correct |
32 |
Correct |
124 ms |
620 KB |
Output is correct |
33 |
Correct |
103 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
122 ms |
620 KB |
Output is correct |
36 |
Correct |
125 ms |
748 KB |
Output is correct |
37 |
Correct |
673 ms |
1004 KB |
Output is correct |
38 |
Correct |
678 ms |
1132 KB |
Output is correct |
39 |
Correct |
638 ms |
520 KB |
Output is correct |
40 |
Execution timed out |
1061 ms |
1260 KB |
Time limit exceeded |
41 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
512 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
52 ms |
492 KB |
Output is correct |
22 |
Correct |
68 ms |
492 KB |
Output is correct |
23 |
Correct |
33 ms |
492 KB |
Output is correct |
24 |
Correct |
111 ms |
624 KB |
Output is correct |
25 |
Correct |
127 ms |
748 KB |
Output is correct |
26 |
Correct |
147 ms |
620 KB |
Output is correct |
27 |
Correct |
131 ms |
620 KB |
Output is correct |
28 |
Correct |
119 ms |
620 KB |
Output is correct |
29 |
Correct |
140 ms |
620 KB |
Output is correct |
30 |
Correct |
131 ms |
764 KB |
Output is correct |
31 |
Correct |
141 ms |
748 KB |
Output is correct |
32 |
Correct |
124 ms |
620 KB |
Output is correct |
33 |
Correct |
103 ms |
492 KB |
Output is correct |
34 |
Correct |
105 ms |
492 KB |
Output is correct |
35 |
Correct |
122 ms |
620 KB |
Output is correct |
36 |
Correct |
125 ms |
748 KB |
Output is correct |
37 |
Correct |
673 ms |
1004 KB |
Output is correct |
38 |
Correct |
678 ms |
1132 KB |
Output is correct |
39 |
Correct |
638 ms |
520 KB |
Output is correct |
40 |
Execution timed out |
1061 ms |
1260 KB |
Time limit exceeded |
41 |
Halted |
0 ms |
0 KB |
- |