#include <bits/stdc++.h>
#define all(X) X.begin(), X.end()
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int maxn = 1e6 + 10;
const int maxa = 1e6;
const int inf = 2e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const int block = 350;
int main ()
{
ios_base::sync_with_stdio(0); cin.tie();
/*#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
freopen("bootfall.in", "r", stdin);
freopen("bootfall.out", "w", stdout);
#endif*/
int n; cin >> n;
vector <int> a (n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
bitset <25100> st;
int sum = 0;
st[0] = 1;
for (int i = 0; i < n; i++) {
st |= (st << a[i]);
sum += a[i];
}
if (!(sum & 1) && !st[sum >> 1]) {
cout << 0;
return 0;
}
vector <int> ans;
for (int ins = 1; ins <= n * 500; ins++) {
bool ok = true;
for (int i = 0; i < n; i++) {
st = 0;
st[0] = 1;
sum = 0;
for (int j = 0; j < n; j++) {
if (i != j) {
st |= (st << a[j]);
sum += a[j];
}
}
st |= (st << ins);
sum += ins;
if ((sum & 1)) {
ok = false;
break;
}
else if (!st[sum >> 1]) {
ok = false;
break;
}
}
if (ok) {
ans.push_back(ins);
}
}
cout << sz(ans) << endl;
for (auto i : ans) {
cout << i << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
79 ms |
204 KB |
Output is correct |
6 |
Correct |
29 ms |
316 KB |
Output is correct |
7 |
Correct |
16 ms |
204 KB |
Output is correct |
8 |
Correct |
85 ms |
316 KB |
Output is correct |
9 |
Correct |
44 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
79 ms |
204 KB |
Output is correct |
6 |
Correct |
29 ms |
316 KB |
Output is correct |
7 |
Correct |
16 ms |
204 KB |
Output is correct |
8 |
Correct |
85 ms |
316 KB |
Output is correct |
9 |
Correct |
44 ms |
204 KB |
Output is correct |
10 |
Correct |
380 ms |
304 KB |
Output is correct |
11 |
Correct |
460 ms |
324 KB |
Output is correct |
12 |
Correct |
376 ms |
300 KB |
Output is correct |
13 |
Correct |
283 ms |
312 KB |
Output is correct |
14 |
Correct |
431 ms |
296 KB |
Output is correct |
15 |
Correct |
389 ms |
204 KB |
Output is correct |
16 |
Correct |
475 ms |
296 KB |
Output is correct |
17 |
Correct |
155 ms |
324 KB |
Output is correct |
18 |
Correct |
283 ms |
304 KB |
Output is correct |
19 |
Correct |
320 ms |
204 KB |
Output is correct |
20 |
Correct |
380 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
79 ms |
204 KB |
Output is correct |
6 |
Correct |
29 ms |
316 KB |
Output is correct |
7 |
Correct |
16 ms |
204 KB |
Output is correct |
8 |
Correct |
85 ms |
316 KB |
Output is correct |
9 |
Correct |
44 ms |
204 KB |
Output is correct |
10 |
Correct |
380 ms |
304 KB |
Output is correct |
11 |
Correct |
460 ms |
324 KB |
Output is correct |
12 |
Correct |
376 ms |
300 KB |
Output is correct |
13 |
Correct |
283 ms |
312 KB |
Output is correct |
14 |
Correct |
431 ms |
296 KB |
Output is correct |
15 |
Correct |
389 ms |
204 KB |
Output is correct |
16 |
Correct |
475 ms |
296 KB |
Output is correct |
17 |
Correct |
155 ms |
324 KB |
Output is correct |
18 |
Correct |
283 ms |
304 KB |
Output is correct |
19 |
Correct |
320 ms |
204 KB |
Output is correct |
20 |
Correct |
380 ms |
300 KB |
Output is correct |
21 |
Execution timed out |
1092 ms |
304 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
79 ms |
204 KB |
Output is correct |
6 |
Correct |
29 ms |
316 KB |
Output is correct |
7 |
Correct |
16 ms |
204 KB |
Output is correct |
8 |
Correct |
85 ms |
316 KB |
Output is correct |
9 |
Correct |
44 ms |
204 KB |
Output is correct |
10 |
Correct |
380 ms |
304 KB |
Output is correct |
11 |
Correct |
460 ms |
324 KB |
Output is correct |
12 |
Correct |
376 ms |
300 KB |
Output is correct |
13 |
Correct |
283 ms |
312 KB |
Output is correct |
14 |
Correct |
431 ms |
296 KB |
Output is correct |
15 |
Correct |
389 ms |
204 KB |
Output is correct |
16 |
Correct |
475 ms |
296 KB |
Output is correct |
17 |
Correct |
155 ms |
324 KB |
Output is correct |
18 |
Correct |
283 ms |
304 KB |
Output is correct |
19 |
Correct |
320 ms |
204 KB |
Output is correct |
20 |
Correct |
380 ms |
300 KB |
Output is correct |
21 |
Execution timed out |
1092 ms |
304 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
79 ms |
204 KB |
Output is correct |
6 |
Correct |
29 ms |
316 KB |
Output is correct |
7 |
Correct |
16 ms |
204 KB |
Output is correct |
8 |
Correct |
85 ms |
316 KB |
Output is correct |
9 |
Correct |
44 ms |
204 KB |
Output is correct |
10 |
Correct |
380 ms |
304 KB |
Output is correct |
11 |
Correct |
460 ms |
324 KB |
Output is correct |
12 |
Correct |
376 ms |
300 KB |
Output is correct |
13 |
Correct |
283 ms |
312 KB |
Output is correct |
14 |
Correct |
431 ms |
296 KB |
Output is correct |
15 |
Correct |
389 ms |
204 KB |
Output is correct |
16 |
Correct |
475 ms |
296 KB |
Output is correct |
17 |
Correct |
155 ms |
324 KB |
Output is correct |
18 |
Correct |
283 ms |
304 KB |
Output is correct |
19 |
Correct |
320 ms |
204 KB |
Output is correct |
20 |
Correct |
380 ms |
300 KB |
Output is correct |
21 |
Execution timed out |
1092 ms |
304 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
79 ms |
204 KB |
Output is correct |
6 |
Correct |
29 ms |
316 KB |
Output is correct |
7 |
Correct |
16 ms |
204 KB |
Output is correct |
8 |
Correct |
85 ms |
316 KB |
Output is correct |
9 |
Correct |
44 ms |
204 KB |
Output is correct |
10 |
Correct |
380 ms |
304 KB |
Output is correct |
11 |
Correct |
460 ms |
324 KB |
Output is correct |
12 |
Correct |
376 ms |
300 KB |
Output is correct |
13 |
Correct |
283 ms |
312 KB |
Output is correct |
14 |
Correct |
431 ms |
296 KB |
Output is correct |
15 |
Correct |
389 ms |
204 KB |
Output is correct |
16 |
Correct |
475 ms |
296 KB |
Output is correct |
17 |
Correct |
155 ms |
324 KB |
Output is correct |
18 |
Correct |
283 ms |
304 KB |
Output is correct |
19 |
Correct |
320 ms |
204 KB |
Output is correct |
20 |
Correct |
380 ms |
300 KB |
Output is correct |
21 |
Execution timed out |
1092 ms |
304 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |