Submission #444342

# Submission time Handle Problem Language Result Execution time Memory
444342 2021-07-13T17:32:34 Z KiriLL1ca Bootfall (IZhO17_bootfall) C++14
13 / 100
45 ms 2388 KB
#include <bits/stdc++.h>

using namespace std;

/* 
written on phone :)))))
*/

const int N = 505;

long long dp[N*N];
int ans[N*N];

void add (int x) {
    for (int i = N*N-1; i >= x; i--) {
        dp[i] += dp[i-x];
    }
}

void del (int x) {
    for (int i = x; i < N*N; i++) {
        dp[i] -= dp[i-x];
    }
}

int main ()
{
    dp[0] = 1;
    int n; cin >> n;
    vector <int> a (n);
    bitset <N*N> d; d[0]=1;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        d |= (d << a[i]);
        sum += a[i];
        add(a[i]);
    }
    if (sum & 1) {
        cout << 0; return 0;
    }
    if (!d[sum >> 1]) {
        cout << 0; return 0;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        del(a[i]); sum-=a[i];
        for (int j = sum&1; j <= N*N; j += 2) {
            int need = ((sum+j)>>1)-j;
            if (need >= 0 && dp[need] > 0) {
                ans[j]++;
            }
        }
        add(a[i]); sum+=a[i];
    }
    for (int i = 0; i < N*N;i++) {
        if (ans[i] == n) 
            cnt++;
    }
    cout << cnt << endl;
    for (int i = 0; i < N*N;i++) {
        if (ans[i] == n) 
            cout << i << " ";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2364 KB Output is correct
2 Correct 6 ms 2380 KB Output is correct
3 Correct 3 ms 2380 KB Output is correct
4 Correct 5 ms 2380 KB Output is correct
5 Correct 9 ms 2384 KB Output is correct
6 Correct 7 ms 2380 KB Output is correct
7 Correct 6 ms 2380 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 8 ms 2376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2364 KB Output is correct
2 Correct 6 ms 2380 KB Output is correct
3 Correct 3 ms 2380 KB Output is correct
4 Correct 5 ms 2380 KB Output is correct
5 Correct 9 ms 2384 KB Output is correct
6 Correct 7 ms 2380 KB Output is correct
7 Correct 6 ms 2380 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 8 ms 2376 KB Output is correct
10 Correct 19 ms 2380 KB Output is correct
11 Correct 21 ms 2380 KB Output is correct
12 Correct 20 ms 2384 KB Output is correct
13 Correct 18 ms 2380 KB Output is correct
14 Correct 19 ms 2380 KB Output is correct
15 Correct 27 ms 2380 KB Output is correct
16 Correct 22 ms 2384 KB Output is correct
17 Correct 13 ms 2380 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2388 KB Output is correct
20 Correct 19 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2364 KB Output is correct
2 Correct 6 ms 2380 KB Output is correct
3 Correct 3 ms 2380 KB Output is correct
4 Correct 5 ms 2380 KB Output is correct
5 Correct 9 ms 2384 KB Output is correct
6 Correct 7 ms 2380 KB Output is correct
7 Correct 6 ms 2380 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 8 ms 2376 KB Output is correct
10 Correct 19 ms 2380 KB Output is correct
11 Correct 21 ms 2380 KB Output is correct
12 Correct 20 ms 2384 KB Output is correct
13 Correct 18 ms 2380 KB Output is correct
14 Correct 19 ms 2380 KB Output is correct
15 Correct 27 ms 2380 KB Output is correct
16 Correct 22 ms 2384 KB Output is correct
17 Correct 13 ms 2380 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2388 KB Output is correct
20 Correct 19 ms 2252 KB Output is correct
21 Correct 39 ms 2384 KB Output is correct
22 Incorrect 45 ms 2384 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2364 KB Output is correct
2 Correct 6 ms 2380 KB Output is correct
3 Correct 3 ms 2380 KB Output is correct
4 Correct 5 ms 2380 KB Output is correct
5 Correct 9 ms 2384 KB Output is correct
6 Correct 7 ms 2380 KB Output is correct
7 Correct 6 ms 2380 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 8 ms 2376 KB Output is correct
10 Correct 19 ms 2380 KB Output is correct
11 Correct 21 ms 2380 KB Output is correct
12 Correct 20 ms 2384 KB Output is correct
13 Correct 18 ms 2380 KB Output is correct
14 Correct 19 ms 2380 KB Output is correct
15 Correct 27 ms 2380 KB Output is correct
16 Correct 22 ms 2384 KB Output is correct
17 Correct 13 ms 2380 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2388 KB Output is correct
20 Correct 19 ms 2252 KB Output is correct
21 Correct 39 ms 2384 KB Output is correct
22 Incorrect 45 ms 2384 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2364 KB Output is correct
2 Correct 6 ms 2380 KB Output is correct
3 Correct 3 ms 2380 KB Output is correct
4 Correct 5 ms 2380 KB Output is correct
5 Correct 9 ms 2384 KB Output is correct
6 Correct 7 ms 2380 KB Output is correct
7 Correct 6 ms 2380 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 8 ms 2376 KB Output is correct
10 Correct 19 ms 2380 KB Output is correct
11 Correct 21 ms 2380 KB Output is correct
12 Correct 20 ms 2384 KB Output is correct
13 Correct 18 ms 2380 KB Output is correct
14 Correct 19 ms 2380 KB Output is correct
15 Correct 27 ms 2380 KB Output is correct
16 Correct 22 ms 2384 KB Output is correct
17 Correct 13 ms 2380 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2388 KB Output is correct
20 Correct 19 ms 2252 KB Output is correct
21 Correct 39 ms 2384 KB Output is correct
22 Incorrect 45 ms 2384 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2364 KB Output is correct
2 Correct 6 ms 2380 KB Output is correct
3 Correct 3 ms 2380 KB Output is correct
4 Correct 5 ms 2380 KB Output is correct
5 Correct 9 ms 2384 KB Output is correct
6 Correct 7 ms 2380 KB Output is correct
7 Correct 6 ms 2380 KB Output is correct
8 Correct 9 ms 2380 KB Output is correct
9 Correct 8 ms 2376 KB Output is correct
10 Correct 19 ms 2380 KB Output is correct
11 Correct 21 ms 2380 KB Output is correct
12 Correct 20 ms 2384 KB Output is correct
13 Correct 18 ms 2380 KB Output is correct
14 Correct 19 ms 2380 KB Output is correct
15 Correct 27 ms 2380 KB Output is correct
16 Correct 22 ms 2384 KB Output is correct
17 Correct 13 ms 2380 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2388 KB Output is correct
20 Correct 19 ms 2252 KB Output is correct
21 Correct 39 ms 2384 KB Output is correct
22 Incorrect 45 ms 2384 KB Output isn't correct
23 Halted 0 ms 0 KB -