#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 555
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO cin.tie(NULL);cout.tie(NULL);
#define taskname "BOOTFALL"
using namespace std;
int n, a[N];
vector<int> res;
bitset<N * N> dp[N];
int main() {
// freopen(taskname".inp","r",stdin);
// freopen(taskname".out","w",stdout);
IO;
scanf("%d", &n);
int all = 0;
FOR(i, 1, n) scanf("%d", &a[i]);
FOR(i, 1, n) all += a[i];
FOR(banned, 0, n) {
dp[banned].set(0);
int total = 0;
FOR(i, 1, n) if (i != banned) {
total += a[i];
FORD(S, total, a[i]) {
if (dp[banned][S - a[i]]) {
dp[banned].set(S);
}
}
}
// FOR(S, 0, all) if (dp[banned][S]) cerr << S << ' '; cerr << endl;
}
FOR(value, 1, all) {
bool ok = true;
if (all % 2 != 0 || dp[0][all / 2] == false) continue;
FOR(i, 1, n) {
if ((all + value - a[i]) % 2 == 1 || all - a[i] < value) {
ok = false; break;
}
else {
int newMid = (all - a[i] + value) / 2;
if (dp[i][newMid - value] == false) {
ok = false; break;
}
}
}
if (ok) res.push_back(value);
}
printf("%d\n", res.size());
for (int value : res) printf("%d ", value);
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:52:30: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
printf("%d\n", res.size());
^
bootfall.cpp:19:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
bootfall.cpp:21:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
FOR(i, 1, n) scanf("%d", &a[i]);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
22884 KB |
Output is correct |
2 |
Correct |
0 ms |
22884 KB |
Output is correct |
3 |
Correct |
0 ms |
22884 KB |
Output is correct |
4 |
Correct |
0 ms |
22884 KB |
Output is correct |
5 |
Correct |
0 ms |
22884 KB |
Output is correct |
6 |
Correct |
0 ms |
22884 KB |
Output is correct |
7 |
Correct |
0 ms |
22884 KB |
Output is correct |
8 |
Correct |
0 ms |
22884 KB |
Output is correct |
9 |
Correct |
0 ms |
22884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
22884 KB |
Output is correct |
2 |
Correct |
0 ms |
22884 KB |
Output is correct |
3 |
Correct |
0 ms |
22884 KB |
Output is correct |
4 |
Correct |
0 ms |
22884 KB |
Output is correct |
5 |
Correct |
0 ms |
22884 KB |
Output is correct |
6 |
Correct |
0 ms |
22884 KB |
Output is correct |
7 |
Correct |
0 ms |
22884 KB |
Output is correct |
8 |
Correct |
0 ms |
22884 KB |
Output is correct |
9 |
Correct |
0 ms |
22884 KB |
Output is correct |
10 |
Correct |
0 ms |
22884 KB |
Output is correct |
11 |
Correct |
0 ms |
22884 KB |
Output is correct |
12 |
Correct |
0 ms |
22884 KB |
Output is correct |
13 |
Correct |
0 ms |
22884 KB |
Output is correct |
14 |
Correct |
0 ms |
22884 KB |
Output is correct |
15 |
Correct |
0 ms |
22884 KB |
Output is correct |
16 |
Correct |
0 ms |
22884 KB |
Output is correct |
17 |
Correct |
0 ms |
22884 KB |
Output is correct |
18 |
Correct |
0 ms |
22884 KB |
Output is correct |
19 |
Correct |
0 ms |
22884 KB |
Output is correct |
20 |
Correct |
0 ms |
22884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
22884 KB |
Output is correct |
2 |
Correct |
0 ms |
22884 KB |
Output is correct |
3 |
Correct |
0 ms |
22884 KB |
Output is correct |
4 |
Correct |
0 ms |
22884 KB |
Output is correct |
5 |
Correct |
0 ms |
22884 KB |
Output is correct |
6 |
Correct |
0 ms |
22884 KB |
Output is correct |
7 |
Correct |
0 ms |
22884 KB |
Output is correct |
8 |
Correct |
0 ms |
22884 KB |
Output is correct |
9 |
Correct |
0 ms |
22884 KB |
Output is correct |
10 |
Correct |
0 ms |
22884 KB |
Output is correct |
11 |
Correct |
0 ms |
22884 KB |
Output is correct |
12 |
Correct |
0 ms |
22884 KB |
Output is correct |
13 |
Correct |
0 ms |
22884 KB |
Output is correct |
14 |
Correct |
0 ms |
22884 KB |
Output is correct |
15 |
Correct |
0 ms |
22884 KB |
Output is correct |
16 |
Correct |
0 ms |
22884 KB |
Output is correct |
17 |
Correct |
0 ms |
22884 KB |
Output is correct |
18 |
Correct |
0 ms |
22884 KB |
Output is correct |
19 |
Correct |
0 ms |
22884 KB |
Output is correct |
20 |
Correct |
0 ms |
22884 KB |
Output is correct |
21 |
Correct |
19 ms |
22884 KB |
Output is correct |
22 |
Correct |
33 ms |
22884 KB |
Output is correct |
23 |
Correct |
9 ms |
22884 KB |
Output is correct |
24 |
Correct |
89 ms |
22884 KB |
Output is correct |
25 |
Correct |
133 ms |
22884 KB |
Output is correct |
26 |
Correct |
126 ms |
22884 KB |
Output is correct |
27 |
Correct |
106 ms |
22884 KB |
Output is correct |
28 |
Correct |
103 ms |
22884 KB |
Output is correct |
29 |
Correct |
123 ms |
22884 KB |
Output is correct |
30 |
Correct |
76 ms |
22884 KB |
Output is correct |
31 |
Correct |
116 ms |
22884 KB |
Output is correct |
32 |
Correct |
69 ms |
22884 KB |
Output is correct |
33 |
Correct |
89 ms |
22884 KB |
Output is correct |
34 |
Correct |
89 ms |
22884 KB |
Output is correct |
35 |
Correct |
106 ms |
22884 KB |
Output is correct |
36 |
Correct |
73 ms |
22884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
22884 KB |
Output is correct |
2 |
Correct |
0 ms |
22884 KB |
Output is correct |
3 |
Correct |
0 ms |
22884 KB |
Output is correct |
4 |
Correct |
0 ms |
22884 KB |
Output is correct |
5 |
Correct |
0 ms |
22884 KB |
Output is correct |
6 |
Correct |
0 ms |
22884 KB |
Output is correct |
7 |
Correct |
0 ms |
22884 KB |
Output is correct |
8 |
Correct |
0 ms |
22884 KB |
Output is correct |
9 |
Correct |
0 ms |
22884 KB |
Output is correct |
10 |
Correct |
0 ms |
22884 KB |
Output is correct |
11 |
Correct |
0 ms |
22884 KB |
Output is correct |
12 |
Correct |
0 ms |
22884 KB |
Output is correct |
13 |
Correct |
0 ms |
22884 KB |
Output is correct |
14 |
Correct |
0 ms |
22884 KB |
Output is correct |
15 |
Correct |
0 ms |
22884 KB |
Output is correct |
16 |
Correct |
0 ms |
22884 KB |
Output is correct |
17 |
Correct |
0 ms |
22884 KB |
Output is correct |
18 |
Correct |
0 ms |
22884 KB |
Output is correct |
19 |
Correct |
0 ms |
22884 KB |
Output is correct |
20 |
Correct |
0 ms |
22884 KB |
Output is correct |
21 |
Correct |
19 ms |
22884 KB |
Output is correct |
22 |
Correct |
33 ms |
22884 KB |
Output is correct |
23 |
Correct |
9 ms |
22884 KB |
Output is correct |
24 |
Correct |
89 ms |
22884 KB |
Output is correct |
25 |
Correct |
133 ms |
22884 KB |
Output is correct |
26 |
Correct |
126 ms |
22884 KB |
Output is correct |
27 |
Correct |
106 ms |
22884 KB |
Output is correct |
28 |
Correct |
103 ms |
22884 KB |
Output is correct |
29 |
Correct |
123 ms |
22884 KB |
Output is correct |
30 |
Correct |
76 ms |
22884 KB |
Output is correct |
31 |
Correct |
116 ms |
22884 KB |
Output is correct |
32 |
Correct |
69 ms |
22884 KB |
Output is correct |
33 |
Correct |
89 ms |
22884 KB |
Output is correct |
34 |
Correct |
89 ms |
22884 KB |
Output is correct |
35 |
Correct |
106 ms |
22884 KB |
Output is correct |
36 |
Correct |
73 ms |
22884 KB |
Output is correct |
37 |
Execution timed out |
1000 ms |
23024 KB |
Execution timed out |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
22884 KB |
Output is correct |
2 |
Correct |
0 ms |
22884 KB |
Output is correct |
3 |
Correct |
0 ms |
22884 KB |
Output is correct |
4 |
Correct |
0 ms |
22884 KB |
Output is correct |
5 |
Correct |
0 ms |
22884 KB |
Output is correct |
6 |
Correct |
0 ms |
22884 KB |
Output is correct |
7 |
Correct |
0 ms |
22884 KB |
Output is correct |
8 |
Correct |
0 ms |
22884 KB |
Output is correct |
9 |
Correct |
0 ms |
22884 KB |
Output is correct |
10 |
Correct |
0 ms |
22884 KB |
Output is correct |
11 |
Correct |
0 ms |
22884 KB |
Output is correct |
12 |
Correct |
0 ms |
22884 KB |
Output is correct |
13 |
Correct |
0 ms |
22884 KB |
Output is correct |
14 |
Correct |
0 ms |
22884 KB |
Output is correct |
15 |
Correct |
0 ms |
22884 KB |
Output is correct |
16 |
Correct |
0 ms |
22884 KB |
Output is correct |
17 |
Correct |
0 ms |
22884 KB |
Output is correct |
18 |
Correct |
0 ms |
22884 KB |
Output is correct |
19 |
Correct |
0 ms |
22884 KB |
Output is correct |
20 |
Correct |
0 ms |
22884 KB |
Output is correct |
21 |
Correct |
19 ms |
22884 KB |
Output is correct |
22 |
Correct |
33 ms |
22884 KB |
Output is correct |
23 |
Correct |
9 ms |
22884 KB |
Output is correct |
24 |
Correct |
89 ms |
22884 KB |
Output is correct |
25 |
Correct |
133 ms |
22884 KB |
Output is correct |
26 |
Correct |
126 ms |
22884 KB |
Output is correct |
27 |
Correct |
106 ms |
22884 KB |
Output is correct |
28 |
Correct |
103 ms |
22884 KB |
Output is correct |
29 |
Correct |
123 ms |
22884 KB |
Output is correct |
30 |
Correct |
76 ms |
22884 KB |
Output is correct |
31 |
Correct |
116 ms |
22884 KB |
Output is correct |
32 |
Correct |
69 ms |
22884 KB |
Output is correct |
33 |
Correct |
89 ms |
22884 KB |
Output is correct |
34 |
Correct |
89 ms |
22884 KB |
Output is correct |
35 |
Correct |
106 ms |
22884 KB |
Output is correct |
36 |
Correct |
73 ms |
22884 KB |
Output is correct |
37 |
Execution timed out |
1000 ms |
23024 KB |
Execution timed out |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
22884 KB |
Output is correct |
2 |
Correct |
0 ms |
22884 KB |
Output is correct |
3 |
Correct |
0 ms |
22884 KB |
Output is correct |
4 |
Correct |
0 ms |
22884 KB |
Output is correct |
5 |
Correct |
0 ms |
22884 KB |
Output is correct |
6 |
Correct |
0 ms |
22884 KB |
Output is correct |
7 |
Correct |
0 ms |
22884 KB |
Output is correct |
8 |
Correct |
0 ms |
22884 KB |
Output is correct |
9 |
Correct |
0 ms |
22884 KB |
Output is correct |
10 |
Correct |
0 ms |
22884 KB |
Output is correct |
11 |
Correct |
0 ms |
22884 KB |
Output is correct |
12 |
Correct |
0 ms |
22884 KB |
Output is correct |
13 |
Correct |
0 ms |
22884 KB |
Output is correct |
14 |
Correct |
0 ms |
22884 KB |
Output is correct |
15 |
Correct |
0 ms |
22884 KB |
Output is correct |
16 |
Correct |
0 ms |
22884 KB |
Output is correct |
17 |
Correct |
0 ms |
22884 KB |
Output is correct |
18 |
Correct |
0 ms |
22884 KB |
Output is correct |
19 |
Correct |
0 ms |
22884 KB |
Output is correct |
20 |
Correct |
0 ms |
22884 KB |
Output is correct |
21 |
Correct |
19 ms |
22884 KB |
Output is correct |
22 |
Correct |
33 ms |
22884 KB |
Output is correct |
23 |
Correct |
9 ms |
22884 KB |
Output is correct |
24 |
Correct |
89 ms |
22884 KB |
Output is correct |
25 |
Correct |
133 ms |
22884 KB |
Output is correct |
26 |
Correct |
126 ms |
22884 KB |
Output is correct |
27 |
Correct |
106 ms |
22884 KB |
Output is correct |
28 |
Correct |
103 ms |
22884 KB |
Output is correct |
29 |
Correct |
123 ms |
22884 KB |
Output is correct |
30 |
Correct |
76 ms |
22884 KB |
Output is correct |
31 |
Correct |
116 ms |
22884 KB |
Output is correct |
32 |
Correct |
69 ms |
22884 KB |
Output is correct |
33 |
Correct |
89 ms |
22884 KB |
Output is correct |
34 |
Correct |
89 ms |
22884 KB |
Output is correct |
35 |
Correct |
106 ms |
22884 KB |
Output is correct |
36 |
Correct |
73 ms |
22884 KB |
Output is correct |
37 |
Execution timed out |
1000 ms |
23024 KB |
Execution timed out |
38 |
Halted |
0 ms |
0 KB |
- |