Submission #331660

# Submission time Handle Problem Language Result Execution time Memory
331660 2020-11-29T12:12:03 Z vitkishloh228 Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 492 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
const int maxc = 10000;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int S = 0;
    for (auto elem : a) {
        S += elem;
    }
    bitset<maxc> dp1;
    dp1[0] = 1;
    for (int i = 0; i < n; i++) {
        dp1 |= dp1 << a[i];
    }
    vector<int> ans;
    for (int L = 0; L < 3000; ++L) {
        int needsum = (S + L);
        bool ok = dp1[S / 2];
        if (!ok) {
            cout << 0;
            return 0;
        }
        for (int j = 0; j < n; ++j) {
            if (((S + L - a[j]) & 1) == 1) {
                ok = false;
                break;
            }
            bitset<maxc> dp;
            dp[0] = 1;
            for (int i = 0; i < n; i++) {
                if (i == j) continue;
                dp |= dp << a[i];
            }
            dp |= dp << L;
            if (!dp[(S + L - a[j]) / 2]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans.push_back(L);
        }
    }
    cout << ans.size() << '\n';
    for (auto elem : ans) cout << elem << ' ';
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:23:13: warning: unused variable 'needsum' [-Wunused-variable]
   23 |         int needsum = (S + L);
      |             ^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 17 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 9 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 17 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 9 ms 364 KB Output is correct
10 Correct 30 ms 364 KB Output is correct
11 Correct 64 ms 364 KB Output is correct
12 Correct 20 ms 364 KB Output is correct
13 Correct 17 ms 364 KB Output is correct
14 Correct 64 ms 364 KB Output is correct
15 Correct 53 ms 492 KB Output is correct
16 Correct 65 ms 364 KB Output is correct
17 Correct 21 ms 364 KB Output is correct
18 Correct 40 ms 364 KB Output is correct
19 Correct 42 ms 364 KB Output is correct
20 Correct 24 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 17 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 9 ms 364 KB Output is correct
10 Correct 30 ms 364 KB Output is correct
11 Correct 64 ms 364 KB Output is correct
12 Correct 20 ms 364 KB Output is correct
13 Correct 17 ms 364 KB Output is correct
14 Correct 64 ms 364 KB Output is correct
15 Correct 53 ms 492 KB Output is correct
16 Correct 65 ms 364 KB Output is correct
17 Correct 21 ms 364 KB Output is correct
18 Correct 40 ms 364 KB Output is correct
19 Correct 42 ms 364 KB Output is correct
20 Correct 24 ms 364 KB Output is correct
21 Execution timed out 1095 ms 368 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 17 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 9 ms 364 KB Output is correct
10 Correct 30 ms 364 KB Output is correct
11 Correct 64 ms 364 KB Output is correct
12 Correct 20 ms 364 KB Output is correct
13 Correct 17 ms 364 KB Output is correct
14 Correct 64 ms 364 KB Output is correct
15 Correct 53 ms 492 KB Output is correct
16 Correct 65 ms 364 KB Output is correct
17 Correct 21 ms 364 KB Output is correct
18 Correct 40 ms 364 KB Output is correct
19 Correct 42 ms 364 KB Output is correct
20 Correct 24 ms 364 KB Output is correct
21 Execution timed out 1095 ms 368 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 17 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 9 ms 364 KB Output is correct
10 Correct 30 ms 364 KB Output is correct
11 Correct 64 ms 364 KB Output is correct
12 Correct 20 ms 364 KB Output is correct
13 Correct 17 ms 364 KB Output is correct
14 Correct 64 ms 364 KB Output is correct
15 Correct 53 ms 492 KB Output is correct
16 Correct 65 ms 364 KB Output is correct
17 Correct 21 ms 364 KB Output is correct
18 Correct 40 ms 364 KB Output is correct
19 Correct 42 ms 364 KB Output is correct
20 Correct 24 ms 364 KB Output is correct
21 Execution timed out 1095 ms 368 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 17 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
8 Correct 19 ms 364 KB Output is correct
9 Correct 9 ms 364 KB Output is correct
10 Correct 30 ms 364 KB Output is correct
11 Correct 64 ms 364 KB Output is correct
12 Correct 20 ms 364 KB Output is correct
13 Correct 17 ms 364 KB Output is correct
14 Correct 64 ms 364 KB Output is correct
15 Correct 53 ms 492 KB Output is correct
16 Correct 65 ms 364 KB Output is correct
17 Correct 21 ms 364 KB Output is correct
18 Correct 40 ms 364 KB Output is correct
19 Correct 42 ms 364 KB Output is correct
20 Correct 24 ms 364 KB Output is correct
21 Execution timed out 1095 ms 368 KB Time limit exceeded
22 Halted 0 ms 0 KB -