Submission #36945

# Submission time Handle Problem Language Result Execution time Memory
36945 2017-12-19T14:22:17 Z nickyrio Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 169104 KB
#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;
        FOR(i, 1, n) if (i != banned) {
            FORD(S, all, 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:51: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]);
                                    ^
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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 16 ms 168964 KB Output is correct
22 Correct 26 ms 168964 KB Output is correct
23 Correct 6 ms 168964 KB Output is correct
24 Correct 49 ms 168964 KB Output is correct
25 Correct 113 ms 168964 KB Output is correct
26 Correct 123 ms 168964 KB Output is correct
27 Correct 139 ms 168964 KB Output is correct
28 Correct 123 ms 168964 KB Output is correct
29 Correct 126 ms 168964 KB Output is correct
30 Correct 63 ms 168964 KB Output is correct
31 Correct 96 ms 168964 KB Output is correct
32 Correct 59 ms 168964 KB Output is correct
33 Correct 116 ms 168964 KB Output is correct
34 Correct 119 ms 168964 KB Output is correct
35 Correct 126 ms 168964 KB Output is correct
36 Correct 66 ms 168964 KB Output is correct
# Verdict Execution time Memory 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 16 ms 168964 KB Output is correct
22 Correct 26 ms 168964 KB Output is correct
23 Correct 6 ms 168964 KB Output is correct
24 Correct 49 ms 168964 KB Output is correct
25 Correct 113 ms 168964 KB Output is correct
26 Correct 123 ms 168964 KB Output is correct
27 Correct 139 ms 168964 KB Output is correct
28 Correct 123 ms 168964 KB Output is correct
29 Correct 126 ms 168964 KB Output is correct
30 Correct 63 ms 168964 KB Output is correct
31 Correct 96 ms 168964 KB Output is correct
32 Correct 59 ms 168964 KB Output is correct
33 Correct 116 ms 168964 KB Output is correct
34 Correct 119 ms 168964 KB Output is correct
35 Correct 126 ms 168964 KB Output is correct
36 Correct 66 ms 168964 KB Output is correct
37 Correct 959 ms 169104 KB Output is correct
38 Execution timed out 1000 ms 169104 KB Execution timed out
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 16 ms 168964 KB Output is correct
22 Correct 26 ms 168964 KB Output is correct
23 Correct 6 ms 168964 KB Output is correct
24 Correct 49 ms 168964 KB Output is correct
25 Correct 113 ms 168964 KB Output is correct
26 Correct 123 ms 168964 KB Output is correct
27 Correct 139 ms 168964 KB Output is correct
28 Correct 123 ms 168964 KB Output is correct
29 Correct 126 ms 168964 KB Output is correct
30 Correct 63 ms 168964 KB Output is correct
31 Correct 96 ms 168964 KB Output is correct
32 Correct 59 ms 168964 KB Output is correct
33 Correct 116 ms 168964 KB Output is correct
34 Correct 119 ms 168964 KB Output is correct
35 Correct 126 ms 168964 KB Output is correct
36 Correct 66 ms 168964 KB Output is correct
37 Correct 959 ms 169104 KB Output is correct
38 Execution timed out 1000 ms 169104 KB Execution timed out
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 16 ms 168964 KB Output is correct
22 Correct 26 ms 168964 KB Output is correct
23 Correct 6 ms 168964 KB Output is correct
24 Correct 49 ms 168964 KB Output is correct
25 Correct 113 ms 168964 KB Output is correct
26 Correct 123 ms 168964 KB Output is correct
27 Correct 139 ms 168964 KB Output is correct
28 Correct 123 ms 168964 KB Output is correct
29 Correct 126 ms 168964 KB Output is correct
30 Correct 63 ms 168964 KB Output is correct
31 Correct 96 ms 168964 KB Output is correct
32 Correct 59 ms 168964 KB Output is correct
33 Correct 116 ms 168964 KB Output is correct
34 Correct 119 ms 168964 KB Output is correct
35 Correct 126 ms 168964 KB Output is correct
36 Correct 66 ms 168964 KB Output is correct
37 Correct 959 ms 169104 KB Output is correct
38 Execution timed out 1000 ms 169104 KB Execution timed out
39 Halted 0 ms 0 KB -