Submission #444355

# Submission time Handle Problem Language Result Execution time Memory
444355 2021-07-13T18:17:20 Z KiriLL1ca Bootfall (IZhO17_bootfall) C++14
100 / 100
489 ms 3920 KB
#include <bits/stdc++.h>

using namespace std;

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

const int N = 505;

unsigned 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 = 1; j < N*N; j++) {
            int need = ((sum+j)>>1)-j;
            if (need >= 0 && dp[need] && (sum+j) % 2 == 0) {
                ans[j]++;
            }
        }
        add(a[i]); sum+=a[i];
    }
    for (int i = 1; i < N*N;i++) {
        if (ans[i] == n) 
            cnt++;
    }
    cout << cnt << endl;
    for (int i = 1; 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 2 ms 2252 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 12 ms 2300 KB Output is correct
6 Correct 8 ms 2296 KB Output is correct
7 Correct 7 ms 2292 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 10 ms 2232 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 2 ms 2252 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 12 ms 2300 KB Output is correct
6 Correct 8 ms 2296 KB Output is correct
7 Correct 7 ms 2292 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 10 ms 2232 KB Output is correct
10 Correct 26 ms 2288 KB Output is correct
11 Correct 28 ms 2292 KB Output is correct
12 Correct 27 ms 2252 KB Output is correct
13 Correct 24 ms 2252 KB Output is correct
14 Correct 25 ms 2288 KB Output is correct
15 Correct 26 ms 2284 KB Output is correct
16 Correct 29 ms 2252 KB Output is correct
17 Correct 17 ms 2288 KB Output is correct
18 Correct 22 ms 2288 KB Output is correct
19 Correct 24 ms 2252 KB Output is correct
20 Correct 26 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 2 ms 2252 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 12 ms 2300 KB Output is correct
6 Correct 8 ms 2296 KB Output is correct
7 Correct 7 ms 2292 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 10 ms 2232 KB Output is correct
10 Correct 26 ms 2288 KB Output is correct
11 Correct 28 ms 2292 KB Output is correct
12 Correct 27 ms 2252 KB Output is correct
13 Correct 24 ms 2252 KB Output is correct
14 Correct 25 ms 2288 KB Output is correct
15 Correct 26 ms 2284 KB Output is correct
16 Correct 29 ms 2252 KB Output is correct
17 Correct 17 ms 2288 KB Output is correct
18 Correct 22 ms 2288 KB Output is correct
19 Correct 24 ms 2252 KB Output is correct
20 Correct 26 ms 2252 KB Output is correct
21 Correct 55 ms 2296 KB Output is correct
22 Correct 64 ms 2252 KB Output is correct
23 Correct 44 ms 2252 KB Output is correct
24 Correct 80 ms 2292 KB Output is correct
25 Correct 78 ms 2288 KB Output is correct
26 Correct 84 ms 2312 KB Output is correct
27 Correct 86 ms 2284 KB Output is correct
28 Correct 86 ms 2292 KB Output is correct
29 Correct 94 ms 2316 KB Output is correct
30 Correct 84 ms 2284 KB Output is correct
31 Correct 84 ms 2420 KB Output is correct
32 Correct 84 ms 2292 KB Output is correct
33 Correct 82 ms 2312 KB Output is correct
34 Correct 82 ms 2312 KB Output is correct
35 Correct 84 ms 2252 KB Output is correct
36 Correct 85 ms 2404 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 2 ms 2252 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 12 ms 2300 KB Output is correct
6 Correct 8 ms 2296 KB Output is correct
7 Correct 7 ms 2292 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 10 ms 2232 KB Output is correct
10 Correct 26 ms 2288 KB Output is correct
11 Correct 28 ms 2292 KB Output is correct
12 Correct 27 ms 2252 KB Output is correct
13 Correct 24 ms 2252 KB Output is correct
14 Correct 25 ms 2288 KB Output is correct
15 Correct 26 ms 2284 KB Output is correct
16 Correct 29 ms 2252 KB Output is correct
17 Correct 17 ms 2288 KB Output is correct
18 Correct 22 ms 2288 KB Output is correct
19 Correct 24 ms 2252 KB Output is correct
20 Correct 26 ms 2252 KB Output is correct
21 Correct 55 ms 2296 KB Output is correct
22 Correct 64 ms 2252 KB Output is correct
23 Correct 44 ms 2252 KB Output is correct
24 Correct 80 ms 2292 KB Output is correct
25 Correct 78 ms 2288 KB Output is correct
26 Correct 84 ms 2312 KB Output is correct
27 Correct 86 ms 2284 KB Output is correct
28 Correct 86 ms 2292 KB Output is correct
29 Correct 94 ms 2316 KB Output is correct
30 Correct 84 ms 2284 KB Output is correct
31 Correct 84 ms 2420 KB Output is correct
32 Correct 84 ms 2292 KB Output is correct
33 Correct 82 ms 2312 KB Output is correct
34 Correct 82 ms 2312 KB Output is correct
35 Correct 84 ms 2252 KB Output is correct
36 Correct 85 ms 2404 KB Output is correct
37 Correct 167 ms 2352 KB Output is correct
38 Correct 167 ms 2372 KB Output is correct
39 Correct 212 ms 2520 KB Output is correct
40 Correct 227 ms 2416 KB Output is correct
41 Correct 231 ms 2536 KB Output is correct
42 Correct 211 ms 2500 KB Output is correct
43 Correct 206 ms 2536 KB Output is correct
44 Correct 217 ms 2676 KB Output is correct
45 Correct 215 ms 2628 KB Output is correct
46 Correct 224 ms 2500 KB Output is correct
47 Correct 208 ms 2416 KB Output is correct
48 Correct 217 ms 2500 KB Output is correct
49 Correct 213 ms 2532 KB Output is correct
50 Correct 215 ms 2500 KB Output is correct
51 Correct 69 ms 2252 KB Output is correct
52 Correct 242 ms 2660 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 2 ms 2252 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 12 ms 2300 KB Output is correct
6 Correct 8 ms 2296 KB Output is correct
7 Correct 7 ms 2292 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 10 ms 2232 KB Output is correct
10 Correct 26 ms 2288 KB Output is correct
11 Correct 28 ms 2292 KB Output is correct
12 Correct 27 ms 2252 KB Output is correct
13 Correct 24 ms 2252 KB Output is correct
14 Correct 25 ms 2288 KB Output is correct
15 Correct 26 ms 2284 KB Output is correct
16 Correct 29 ms 2252 KB Output is correct
17 Correct 17 ms 2288 KB Output is correct
18 Correct 22 ms 2288 KB Output is correct
19 Correct 24 ms 2252 KB Output is correct
20 Correct 26 ms 2252 KB Output is correct
21 Correct 55 ms 2296 KB Output is correct
22 Correct 64 ms 2252 KB Output is correct
23 Correct 44 ms 2252 KB Output is correct
24 Correct 80 ms 2292 KB Output is correct
25 Correct 78 ms 2288 KB Output is correct
26 Correct 84 ms 2312 KB Output is correct
27 Correct 86 ms 2284 KB Output is correct
28 Correct 86 ms 2292 KB Output is correct
29 Correct 94 ms 2316 KB Output is correct
30 Correct 84 ms 2284 KB Output is correct
31 Correct 84 ms 2420 KB Output is correct
32 Correct 84 ms 2292 KB Output is correct
33 Correct 82 ms 2312 KB Output is correct
34 Correct 82 ms 2312 KB Output is correct
35 Correct 84 ms 2252 KB Output is correct
36 Correct 85 ms 2404 KB Output is correct
37 Correct 167 ms 2352 KB Output is correct
38 Correct 167 ms 2372 KB Output is correct
39 Correct 212 ms 2520 KB Output is correct
40 Correct 227 ms 2416 KB Output is correct
41 Correct 231 ms 2536 KB Output is correct
42 Correct 211 ms 2500 KB Output is correct
43 Correct 206 ms 2536 KB Output is correct
44 Correct 217 ms 2676 KB Output is correct
45 Correct 215 ms 2628 KB Output is correct
46 Correct 224 ms 2500 KB Output is correct
47 Correct 208 ms 2416 KB Output is correct
48 Correct 217 ms 2500 KB Output is correct
49 Correct 213 ms 2532 KB Output is correct
50 Correct 215 ms 2500 KB Output is correct
51 Correct 69 ms 2252 KB Output is correct
52 Correct 242 ms 2660 KB Output is correct
53 Correct 257 ms 2544 KB Output is correct
54 Correct 297 ms 2632 KB Output is correct
55 Correct 312 ms 2932 KB Output is correct
56 Correct 259 ms 2628 KB Output is correct
57 Correct 312 ms 2928 KB Output is correct
58 Correct 299 ms 2756 KB Output is correct
59 Correct 299 ms 2788 KB Output is correct
60 Correct 95 ms 2252 KB Output is correct
61 Correct 306 ms 2732 KB Output is correct
62 Correct 313 ms 2904 KB Output is correct
63 Correct 283 ms 3056 KB Output is correct
64 Correct 278 ms 2884 KB Output is correct
65 Correct 267 ms 2412 KB Output is correct
66 Correct 260 ms 2472 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 2 ms 2252 KB Output is correct
4 Correct 5 ms 2252 KB Output is correct
5 Correct 12 ms 2300 KB Output is correct
6 Correct 8 ms 2296 KB Output is correct
7 Correct 7 ms 2292 KB Output is correct
8 Correct 12 ms 2252 KB Output is correct
9 Correct 10 ms 2232 KB Output is correct
10 Correct 26 ms 2288 KB Output is correct
11 Correct 28 ms 2292 KB Output is correct
12 Correct 27 ms 2252 KB Output is correct
13 Correct 24 ms 2252 KB Output is correct
14 Correct 25 ms 2288 KB Output is correct
15 Correct 26 ms 2284 KB Output is correct
16 Correct 29 ms 2252 KB Output is correct
17 Correct 17 ms 2288 KB Output is correct
18 Correct 22 ms 2288 KB Output is correct
19 Correct 24 ms 2252 KB Output is correct
20 Correct 26 ms 2252 KB Output is correct
21 Correct 55 ms 2296 KB Output is correct
22 Correct 64 ms 2252 KB Output is correct
23 Correct 44 ms 2252 KB Output is correct
24 Correct 80 ms 2292 KB Output is correct
25 Correct 78 ms 2288 KB Output is correct
26 Correct 84 ms 2312 KB Output is correct
27 Correct 86 ms 2284 KB Output is correct
28 Correct 86 ms 2292 KB Output is correct
29 Correct 94 ms 2316 KB Output is correct
30 Correct 84 ms 2284 KB Output is correct
31 Correct 84 ms 2420 KB Output is correct
32 Correct 84 ms 2292 KB Output is correct
33 Correct 82 ms 2312 KB Output is correct
34 Correct 82 ms 2312 KB Output is correct
35 Correct 84 ms 2252 KB Output is correct
36 Correct 85 ms 2404 KB Output is correct
37 Correct 167 ms 2352 KB Output is correct
38 Correct 167 ms 2372 KB Output is correct
39 Correct 212 ms 2520 KB Output is correct
40 Correct 227 ms 2416 KB Output is correct
41 Correct 231 ms 2536 KB Output is correct
42 Correct 211 ms 2500 KB Output is correct
43 Correct 206 ms 2536 KB Output is correct
44 Correct 217 ms 2676 KB Output is correct
45 Correct 215 ms 2628 KB Output is correct
46 Correct 224 ms 2500 KB Output is correct
47 Correct 208 ms 2416 KB Output is correct
48 Correct 217 ms 2500 KB Output is correct
49 Correct 213 ms 2532 KB Output is correct
50 Correct 215 ms 2500 KB Output is correct
51 Correct 69 ms 2252 KB Output is correct
52 Correct 242 ms 2660 KB Output is correct
53 Correct 257 ms 2544 KB Output is correct
54 Correct 297 ms 2632 KB Output is correct
55 Correct 312 ms 2932 KB Output is correct
56 Correct 259 ms 2628 KB Output is correct
57 Correct 312 ms 2928 KB Output is correct
58 Correct 299 ms 2756 KB Output is correct
59 Correct 299 ms 2788 KB Output is correct
60 Correct 95 ms 2252 KB Output is correct
61 Correct 306 ms 2732 KB Output is correct
62 Correct 313 ms 2904 KB Output is correct
63 Correct 283 ms 3056 KB Output is correct
64 Correct 278 ms 2884 KB Output is correct
65 Correct 267 ms 2412 KB Output is correct
66 Correct 260 ms 2472 KB Output is correct
67 Correct 353 ms 2728 KB Output is correct
68 Correct 134 ms 2276 KB Output is correct
69 Correct 473 ms 3744 KB Output is correct
70 Correct 455 ms 3188 KB Output is correct
71 Correct 450 ms 3268 KB Output is correct
72 Correct 433 ms 2672 KB Output is correct
73 Correct 438 ms 2760 KB Output is correct
74 Correct 476 ms 3920 KB Output is correct
75 Correct 464 ms 3472 KB Output is correct
76 Correct 489 ms 3880 KB Output is correct
77 Correct 481 ms 3908 KB Output is correct