Submission #444344

# Submission time Handle Problem Language Result Execution time Memory
444344 2021-07-13T17:37:55 Z KiriLL1ca Bootfall (IZhO17_bootfall) C++14
13 / 100
47 ms 2380 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-x-1; i >= 0; i--) {
        dp[i+x] += dp[i];
    }
}

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);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        add(a[i]);
    }
    if (sum & 1) {
        cout << 0; return 0;
    }
    if (!dp[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 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2292 KB Output is correct
7 Correct 6 ms 2292 KB Output is correct
8 Correct 9 ms 2296 KB Output is correct
9 Correct 9 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2292 KB Output is correct
7 Correct 6 ms 2292 KB Output is correct
8 Correct 9 ms 2296 KB Output is correct
9 Correct 9 ms 2252 KB Output is correct
10 Correct 20 ms 2252 KB Output is correct
11 Correct 22 ms 2292 KB Output is correct
12 Correct 20 ms 2296 KB Output is correct
13 Correct 18 ms 2252 KB Output is correct
14 Correct 19 ms 2252 KB Output is correct
15 Correct 21 ms 2288 KB Output is correct
16 Correct 23 ms 2292 KB Output is correct
17 Correct 14 ms 2300 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 20 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2292 KB Output is correct
7 Correct 6 ms 2292 KB Output is correct
8 Correct 9 ms 2296 KB Output is correct
9 Correct 9 ms 2252 KB Output is correct
10 Correct 20 ms 2252 KB Output is correct
11 Correct 22 ms 2292 KB Output is correct
12 Correct 20 ms 2296 KB Output is correct
13 Correct 18 ms 2252 KB Output is correct
14 Correct 19 ms 2252 KB Output is correct
15 Correct 21 ms 2288 KB Output is correct
16 Correct 23 ms 2292 KB Output is correct
17 Correct 14 ms 2300 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 20 ms 2380 KB Output is correct
21 Correct 40 ms 2292 KB Output is correct
22 Incorrect 47 ms 2296 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2292 KB Output is correct
7 Correct 6 ms 2292 KB Output is correct
8 Correct 9 ms 2296 KB Output is correct
9 Correct 9 ms 2252 KB Output is correct
10 Correct 20 ms 2252 KB Output is correct
11 Correct 22 ms 2292 KB Output is correct
12 Correct 20 ms 2296 KB Output is correct
13 Correct 18 ms 2252 KB Output is correct
14 Correct 19 ms 2252 KB Output is correct
15 Correct 21 ms 2288 KB Output is correct
16 Correct 23 ms 2292 KB Output is correct
17 Correct 14 ms 2300 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 20 ms 2380 KB Output is correct
21 Correct 40 ms 2292 KB Output is correct
22 Incorrect 47 ms 2296 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2292 KB Output is correct
7 Correct 6 ms 2292 KB Output is correct
8 Correct 9 ms 2296 KB Output is correct
9 Correct 9 ms 2252 KB Output is correct
10 Correct 20 ms 2252 KB Output is correct
11 Correct 22 ms 2292 KB Output is correct
12 Correct 20 ms 2296 KB Output is correct
13 Correct 18 ms 2252 KB Output is correct
14 Correct 19 ms 2252 KB Output is correct
15 Correct 21 ms 2288 KB Output is correct
16 Correct 23 ms 2292 KB Output is correct
17 Correct 14 ms 2300 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 20 ms 2380 KB Output is correct
21 Correct 40 ms 2292 KB Output is correct
22 Incorrect 47 ms 2296 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 3 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2292 KB Output is correct
7 Correct 6 ms 2292 KB Output is correct
8 Correct 9 ms 2296 KB Output is correct
9 Correct 9 ms 2252 KB Output is correct
10 Correct 20 ms 2252 KB Output is correct
11 Correct 22 ms 2292 KB Output is correct
12 Correct 20 ms 2296 KB Output is correct
13 Correct 18 ms 2252 KB Output is correct
14 Correct 19 ms 2252 KB Output is correct
15 Correct 21 ms 2288 KB Output is correct
16 Correct 23 ms 2292 KB Output is correct
17 Correct 14 ms 2300 KB Output is correct
18 Correct 17 ms 2252 KB Output is correct
19 Correct 18 ms 2288 KB Output is correct
20 Correct 20 ms 2380 KB Output is correct
21 Correct 40 ms 2292 KB Output is correct
22 Incorrect 47 ms 2296 KB Output isn't correct
23 Halted 0 ms 0 KB -