Submission #37445

# Submission time Handle Problem Language Result Execution time Memory
37445 2017-12-25T13:46:57 Z HardNut Bootfall (IZhO17_bootfall) C++14
13 / 100
29 ms 4132 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 250005;
const int mod = 1e9 + 7;

typedef long long ll;

int n, a[505], sum;
vector<int> vec;
int ans[N];
int dp[N];

void add(int v) {
    for (int i = sum; i >= 0; i--) {
        dp[i + v] += dp[i];
        dp[i + v] %= mod;
    }
    sum += v;
}

void del(int v) {
    sum -= v;
    for (int i = 0; i <= sum; i++) {
        dp[i + v] = (dp[i + v] - dp[i] + mod) % mod;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        add(a[i]);
    }
    if (sum % 2 == 1) {
        cout << 0;
        return 0;
    }
    for (int i = 1; i <= sum; i++) {
        ans[i] = 1;
    }
    if (!dp[sum / 2]) {
        cout << 0;
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        del(a[i]);
        for (int j = 1; j <= N; j++) {
            if ((sum + j) % 2) {
                ans[j] = 0;
                continue;
            }
            if (!dp[(sum + j) / 2]) {
                ans[j] = 0;
            }
        }
        add(a[i]);
    }
    int cnt = 0;
    for (int i = 1; i <= sum; i++) {
        cnt += ans[i];
    }
    cout << cnt << "\n";
    for (int i = 1; i <= sum; i++)
        if (ans[i])
            cout << i << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4132 KB Output is correct
2 Correct 0 ms 4132 KB Output is correct
3 Correct 0 ms 4132 KB Output is correct
4 Correct 0 ms 4132 KB Output is correct
5 Correct 3 ms 4132 KB Output is correct
6 Correct 0 ms 4132 KB Output is correct
7 Correct 0 ms 4132 KB Output is correct
8 Correct 3 ms 4132 KB Output is correct
9 Correct 3 ms 4132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4132 KB Output is correct
2 Correct 0 ms 4132 KB Output is correct
3 Correct 0 ms 4132 KB Output is correct
4 Correct 0 ms 4132 KB Output is correct
5 Correct 3 ms 4132 KB Output is correct
6 Correct 0 ms 4132 KB Output is correct
7 Correct 0 ms 4132 KB Output is correct
8 Correct 3 ms 4132 KB Output is correct
9 Correct 3 ms 4132 KB Output is correct
10 Correct 9 ms 4132 KB Output is correct
11 Correct 6 ms 4132 KB Output is correct
12 Correct 9 ms 4132 KB Output is correct
13 Correct 6 ms 4132 KB Output is correct
14 Correct 9 ms 4132 KB Output is correct
15 Correct 6 ms 4132 KB Output is correct
16 Correct 9 ms 4132 KB Output is correct
17 Correct 6 ms 4132 KB Output is correct
18 Correct 6 ms 4132 KB Output is correct
19 Correct 9 ms 4132 KB Output is correct
20 Correct 9 ms 4132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4132 KB Output is correct
2 Correct 0 ms 4132 KB Output is correct
3 Correct 0 ms 4132 KB Output is correct
4 Correct 0 ms 4132 KB Output is correct
5 Correct 3 ms 4132 KB Output is correct
6 Correct 0 ms 4132 KB Output is correct
7 Correct 0 ms 4132 KB Output is correct
8 Correct 3 ms 4132 KB Output is correct
9 Correct 3 ms 4132 KB Output is correct
10 Correct 9 ms 4132 KB Output is correct
11 Correct 6 ms 4132 KB Output is correct
12 Correct 9 ms 4132 KB Output is correct
13 Correct 6 ms 4132 KB Output is correct
14 Correct 9 ms 4132 KB Output is correct
15 Correct 6 ms 4132 KB Output is correct
16 Correct 9 ms 4132 KB Output is correct
17 Correct 6 ms 4132 KB Output is correct
18 Correct 6 ms 4132 KB Output is correct
19 Correct 9 ms 4132 KB Output is correct
20 Correct 9 ms 4132 KB Output is correct
21 Correct 23 ms 4132 KB Output is correct
22 Correct 23 ms 4132 KB Output is correct
23 Correct 16 ms 4132 KB Output is correct
24 Runtime error 29 ms 4132 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4132 KB Output is correct
2 Correct 0 ms 4132 KB Output is correct
3 Correct 0 ms 4132 KB Output is correct
4 Correct 0 ms 4132 KB Output is correct
5 Correct 3 ms 4132 KB Output is correct
6 Correct 0 ms 4132 KB Output is correct
7 Correct 0 ms 4132 KB Output is correct
8 Correct 3 ms 4132 KB Output is correct
9 Correct 3 ms 4132 KB Output is correct
10 Correct 9 ms 4132 KB Output is correct
11 Correct 6 ms 4132 KB Output is correct
12 Correct 9 ms 4132 KB Output is correct
13 Correct 6 ms 4132 KB Output is correct
14 Correct 9 ms 4132 KB Output is correct
15 Correct 6 ms 4132 KB Output is correct
16 Correct 9 ms 4132 KB Output is correct
17 Correct 6 ms 4132 KB Output is correct
18 Correct 6 ms 4132 KB Output is correct
19 Correct 9 ms 4132 KB Output is correct
20 Correct 9 ms 4132 KB Output is correct
21 Correct 23 ms 4132 KB Output is correct
22 Correct 23 ms 4132 KB Output is correct
23 Correct 16 ms 4132 KB Output is correct
24 Runtime error 29 ms 4132 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4132 KB Output is correct
2 Correct 0 ms 4132 KB Output is correct
3 Correct 0 ms 4132 KB Output is correct
4 Correct 0 ms 4132 KB Output is correct
5 Correct 3 ms 4132 KB Output is correct
6 Correct 0 ms 4132 KB Output is correct
7 Correct 0 ms 4132 KB Output is correct
8 Correct 3 ms 4132 KB Output is correct
9 Correct 3 ms 4132 KB Output is correct
10 Correct 9 ms 4132 KB Output is correct
11 Correct 6 ms 4132 KB Output is correct
12 Correct 9 ms 4132 KB Output is correct
13 Correct 6 ms 4132 KB Output is correct
14 Correct 9 ms 4132 KB Output is correct
15 Correct 6 ms 4132 KB Output is correct
16 Correct 9 ms 4132 KB Output is correct
17 Correct 6 ms 4132 KB Output is correct
18 Correct 6 ms 4132 KB Output is correct
19 Correct 9 ms 4132 KB Output is correct
20 Correct 9 ms 4132 KB Output is correct
21 Correct 23 ms 4132 KB Output is correct
22 Correct 23 ms 4132 KB Output is correct
23 Correct 16 ms 4132 KB Output is correct
24 Runtime error 29 ms 4132 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 4132 KB Output is correct
2 Correct 0 ms 4132 KB Output is correct
3 Correct 0 ms 4132 KB Output is correct
4 Correct 0 ms 4132 KB Output is correct
5 Correct 3 ms 4132 KB Output is correct
6 Correct 0 ms 4132 KB Output is correct
7 Correct 0 ms 4132 KB Output is correct
8 Correct 3 ms 4132 KB Output is correct
9 Correct 3 ms 4132 KB Output is correct
10 Correct 9 ms 4132 KB Output is correct
11 Correct 6 ms 4132 KB Output is correct
12 Correct 9 ms 4132 KB Output is correct
13 Correct 6 ms 4132 KB Output is correct
14 Correct 9 ms 4132 KB Output is correct
15 Correct 6 ms 4132 KB Output is correct
16 Correct 9 ms 4132 KB Output is correct
17 Correct 6 ms 4132 KB Output is correct
18 Correct 6 ms 4132 KB Output is correct
19 Correct 9 ms 4132 KB Output is correct
20 Correct 9 ms 4132 KB Output is correct
21 Correct 23 ms 4132 KB Output is correct
22 Correct 23 ms 4132 KB Output is correct
23 Correct 16 ms 4132 KB Output is correct
24 Runtime error 29 ms 4132 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -