#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];
bool dp[N][N * N];
vector<int> res;
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][0] = true;
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][S] = true;
}
}
}
// 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:53: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:20:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
bootfall.cpp:22: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 |
168964 KB |
Output is correct |
2 |
Correct |
0 ms |
168964 KB |
Output is correct |
3 |
Correct |
0 ms |
168964 KB |
Output is correct |
4 |
Correct |
0 ms |
168964 KB |
Output is correct |
5 |
Correct |
0 ms |
168964 KB |
Output is correct |
6 |
Correct |
0 ms |
168964 KB |
Output is correct |
7 |
Correct |
0 ms |
168964 KB |
Output is correct |
8 |
Correct |
0 ms |
168964 KB |
Output is correct |
9 |
Correct |
0 ms |
168964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
168964 KB |
Output is correct |
2 |
Correct |
0 ms |
168964 KB |
Output is correct |
3 |
Correct |
0 ms |
168964 KB |
Output is correct |
4 |
Correct |
0 ms |
168964 KB |
Output is correct |
5 |
Correct |
0 ms |
168964 KB |
Output is correct |
6 |
Correct |
0 ms |
168964 KB |
Output is correct |
7 |
Correct |
0 ms |
168964 KB |
Output is correct |
8 |
Correct |
0 ms |
168964 KB |
Output is correct |
9 |
Correct |
0 ms |
168964 KB |
Output is correct |
10 |
Correct |
0 ms |
168964 KB |
Output is correct |
11 |
Correct |
0 ms |
168964 KB |
Output is correct |
12 |
Correct |
0 ms |
168964 KB |
Output is correct |
13 |
Correct |
0 ms |
168964 KB |
Output is correct |
14 |
Correct |
0 ms |
168964 KB |
Output is correct |
15 |
Correct |
0 ms |
168964 KB |
Output is correct |
16 |
Correct |
0 ms |
168964 KB |
Output is correct |
17 |
Correct |
0 ms |
168964 KB |
Output is correct |
18 |
Correct |
0 ms |
168964 KB |
Output is correct |
19 |
Correct |
0 ms |
168964 KB |
Output is correct |
20 |
Correct |
0 ms |
168964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
168964 KB |
Output is correct |
2 |
Correct |
0 ms |
168964 KB |
Output is correct |
3 |
Correct |
0 ms |
168964 KB |
Output is correct |
4 |
Correct |
0 ms |
168964 KB |
Output is correct |
5 |
Correct |
0 ms |
168964 KB |
Output is correct |
6 |
Correct |
0 ms |
168964 KB |
Output is correct |
7 |
Correct |
0 ms |
168964 KB |
Output is correct |
8 |
Correct |
0 ms |
168964 KB |
Output is correct |
9 |
Correct |
0 ms |
168964 KB |
Output is correct |
10 |
Correct |
0 ms |
168964 KB |
Output is correct |
11 |
Correct |
0 ms |
168964 KB |
Output is correct |
12 |
Correct |
0 ms |
168964 KB |
Output is correct |
13 |
Correct |
0 ms |
168964 KB |
Output is correct |
14 |
Correct |
0 ms |
168964 KB |
Output is correct |
15 |
Correct |
0 ms |
168964 KB |
Output is correct |
16 |
Correct |
0 ms |
168964 KB |
Output is correct |
17 |
Correct |
0 ms |
168964 KB |
Output is correct |
18 |
Correct |
0 ms |
168964 KB |
Output is correct |
19 |
Correct |
0 ms |
168964 KB |
Output is correct |
20 |
Correct |
0 ms |
168964 KB |
Output is correct |
21 |
Correct |
9 ms |
168964 KB |
Output is correct |
22 |
Correct |
16 ms |
168964 KB |
Output is correct |
23 |
Correct |
3 ms |
168964 KB |
Output is correct |
24 |
Correct |
26 ms |
168964 KB |
Output is correct |
25 |
Correct |
96 ms |
168964 KB |
Output is correct |
26 |
Correct |
86 ms |
168964 KB |
Output is correct |
27 |
Correct |
63 ms |
168964 KB |
Output is correct |
28 |
Correct |
86 ms |
168964 KB |
Output is correct |
29 |
Correct |
86 ms |
168964 KB |
Output is correct |
30 |
Correct |
29 ms |
168964 KB |
Output is correct |
31 |
Correct |
53 ms |
168964 KB |
Output is correct |
32 |
Correct |
39 ms |
168964 KB |
Output is correct |
33 |
Correct |
59 ms |
168964 KB |
Output is correct |
34 |
Correct |
59 ms |
168964 KB |
Output is correct |
35 |
Correct |
86 ms |
168964 KB |
Output is correct |
36 |
Correct |
29 ms |
168964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
168964 KB |
Output is correct |
2 |
Correct |
0 ms |
168964 KB |
Output is correct |
3 |
Correct |
0 ms |
168964 KB |
Output is correct |
4 |
Correct |
0 ms |
168964 KB |
Output is correct |
5 |
Correct |
0 ms |
168964 KB |
Output is correct |
6 |
Correct |
0 ms |
168964 KB |
Output is correct |
7 |
Correct |
0 ms |
168964 KB |
Output is correct |
8 |
Correct |
0 ms |
168964 KB |
Output is correct |
9 |
Correct |
0 ms |
168964 KB |
Output is correct |
10 |
Correct |
0 ms |
168964 KB |
Output is correct |
11 |
Correct |
0 ms |
168964 KB |
Output is correct |
12 |
Correct |
0 ms |
168964 KB |
Output is correct |
13 |
Correct |
0 ms |
168964 KB |
Output is correct |
14 |
Correct |
0 ms |
168964 KB |
Output is correct |
15 |
Correct |
0 ms |
168964 KB |
Output is correct |
16 |
Correct |
0 ms |
168964 KB |
Output is correct |
17 |
Correct |
0 ms |
168964 KB |
Output is correct |
18 |
Correct |
0 ms |
168964 KB |
Output is correct |
19 |
Correct |
0 ms |
168964 KB |
Output is correct |
20 |
Correct |
0 ms |
168964 KB |
Output is correct |
21 |
Correct |
9 ms |
168964 KB |
Output is correct |
22 |
Correct |
16 ms |
168964 KB |
Output is correct |
23 |
Correct |
3 ms |
168964 KB |
Output is correct |
24 |
Correct |
26 ms |
168964 KB |
Output is correct |
25 |
Correct |
96 ms |
168964 KB |
Output is correct |
26 |
Correct |
86 ms |
168964 KB |
Output is correct |
27 |
Correct |
63 ms |
168964 KB |
Output is correct |
28 |
Correct |
86 ms |
168964 KB |
Output is correct |
29 |
Correct |
86 ms |
168964 KB |
Output is correct |
30 |
Correct |
29 ms |
168964 KB |
Output is correct |
31 |
Correct |
53 ms |
168964 KB |
Output is correct |
32 |
Correct |
39 ms |
168964 KB |
Output is correct |
33 |
Correct |
59 ms |
168964 KB |
Output is correct |
34 |
Correct |
59 ms |
168964 KB |
Output is correct |
35 |
Correct |
86 ms |
168964 KB |
Output is correct |
36 |
Correct |
29 ms |
168964 KB |
Output is correct |
37 |
Correct |
519 ms |
169104 KB |
Output is correct |
38 |
Correct |
639 ms |
169104 KB |
Output is correct |
39 |
Execution timed out |
1000 ms |
168964 KB |
Execution timed out |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
168964 KB |
Output is correct |
2 |
Correct |
0 ms |
168964 KB |
Output is correct |
3 |
Correct |
0 ms |
168964 KB |
Output is correct |
4 |
Correct |
0 ms |
168964 KB |
Output is correct |
5 |
Correct |
0 ms |
168964 KB |
Output is correct |
6 |
Correct |
0 ms |
168964 KB |
Output is correct |
7 |
Correct |
0 ms |
168964 KB |
Output is correct |
8 |
Correct |
0 ms |
168964 KB |
Output is correct |
9 |
Correct |
0 ms |
168964 KB |
Output is correct |
10 |
Correct |
0 ms |
168964 KB |
Output is correct |
11 |
Correct |
0 ms |
168964 KB |
Output is correct |
12 |
Correct |
0 ms |
168964 KB |
Output is correct |
13 |
Correct |
0 ms |
168964 KB |
Output is correct |
14 |
Correct |
0 ms |
168964 KB |
Output is correct |
15 |
Correct |
0 ms |
168964 KB |
Output is correct |
16 |
Correct |
0 ms |
168964 KB |
Output is correct |
17 |
Correct |
0 ms |
168964 KB |
Output is correct |
18 |
Correct |
0 ms |
168964 KB |
Output is correct |
19 |
Correct |
0 ms |
168964 KB |
Output is correct |
20 |
Correct |
0 ms |
168964 KB |
Output is correct |
21 |
Correct |
9 ms |
168964 KB |
Output is correct |
22 |
Correct |
16 ms |
168964 KB |
Output is correct |
23 |
Correct |
3 ms |
168964 KB |
Output is correct |
24 |
Correct |
26 ms |
168964 KB |
Output is correct |
25 |
Correct |
96 ms |
168964 KB |
Output is correct |
26 |
Correct |
86 ms |
168964 KB |
Output is correct |
27 |
Correct |
63 ms |
168964 KB |
Output is correct |
28 |
Correct |
86 ms |
168964 KB |
Output is correct |
29 |
Correct |
86 ms |
168964 KB |
Output is correct |
30 |
Correct |
29 ms |
168964 KB |
Output is correct |
31 |
Correct |
53 ms |
168964 KB |
Output is correct |
32 |
Correct |
39 ms |
168964 KB |
Output is correct |
33 |
Correct |
59 ms |
168964 KB |
Output is correct |
34 |
Correct |
59 ms |
168964 KB |
Output is correct |
35 |
Correct |
86 ms |
168964 KB |
Output is correct |
36 |
Correct |
29 ms |
168964 KB |
Output is correct |
37 |
Correct |
519 ms |
169104 KB |
Output is correct |
38 |
Correct |
639 ms |
169104 KB |
Output is correct |
39 |
Execution timed out |
1000 ms |
168964 KB |
Execution timed out |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
168964 KB |
Output is correct |
2 |
Correct |
0 ms |
168964 KB |
Output is correct |
3 |
Correct |
0 ms |
168964 KB |
Output is correct |
4 |
Correct |
0 ms |
168964 KB |
Output is correct |
5 |
Correct |
0 ms |
168964 KB |
Output is correct |
6 |
Correct |
0 ms |
168964 KB |
Output is correct |
7 |
Correct |
0 ms |
168964 KB |
Output is correct |
8 |
Correct |
0 ms |
168964 KB |
Output is correct |
9 |
Correct |
0 ms |
168964 KB |
Output is correct |
10 |
Correct |
0 ms |
168964 KB |
Output is correct |
11 |
Correct |
0 ms |
168964 KB |
Output is correct |
12 |
Correct |
0 ms |
168964 KB |
Output is correct |
13 |
Correct |
0 ms |
168964 KB |
Output is correct |
14 |
Correct |
0 ms |
168964 KB |
Output is correct |
15 |
Correct |
0 ms |
168964 KB |
Output is correct |
16 |
Correct |
0 ms |
168964 KB |
Output is correct |
17 |
Correct |
0 ms |
168964 KB |
Output is correct |
18 |
Correct |
0 ms |
168964 KB |
Output is correct |
19 |
Correct |
0 ms |
168964 KB |
Output is correct |
20 |
Correct |
0 ms |
168964 KB |
Output is correct |
21 |
Correct |
9 ms |
168964 KB |
Output is correct |
22 |
Correct |
16 ms |
168964 KB |
Output is correct |
23 |
Correct |
3 ms |
168964 KB |
Output is correct |
24 |
Correct |
26 ms |
168964 KB |
Output is correct |
25 |
Correct |
96 ms |
168964 KB |
Output is correct |
26 |
Correct |
86 ms |
168964 KB |
Output is correct |
27 |
Correct |
63 ms |
168964 KB |
Output is correct |
28 |
Correct |
86 ms |
168964 KB |
Output is correct |
29 |
Correct |
86 ms |
168964 KB |
Output is correct |
30 |
Correct |
29 ms |
168964 KB |
Output is correct |
31 |
Correct |
53 ms |
168964 KB |
Output is correct |
32 |
Correct |
39 ms |
168964 KB |
Output is correct |
33 |
Correct |
59 ms |
168964 KB |
Output is correct |
34 |
Correct |
59 ms |
168964 KB |
Output is correct |
35 |
Correct |
86 ms |
168964 KB |
Output is correct |
36 |
Correct |
29 ms |
168964 KB |
Output is correct |
37 |
Correct |
519 ms |
169104 KB |
Output is correct |
38 |
Correct |
639 ms |
169104 KB |
Output is correct |
39 |
Execution timed out |
1000 ms |
168964 KB |
Execution timed out |
40 |
Halted |
0 ms |
0 KB |
- |