Submission #167693

# Submission time Handle Problem Language Result Execution time Memory
167693 2019-12-09T16:36:24 Z muhammad_hokimiyon Bootfall (IZhO17_bootfall) C++14
65 / 100
415 ms 262148 KB
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;

int n;
int a[N];
int d[N];
int d1[510][N];
vector < int > v[N];

void solve()
{
    cin >> n;
    int sum = 0;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
        sum += a[i];
    }
    d[0] = 1;
    for( int i = 1; i <= n; i++ ){
        for( int j = sum; j >= 0; j-- ){
            if( j - a[i] >= 0 ){
                d[j] += d[j - a[i]];
            }
        }
    }
    if( sum % 2 ){
        cout << "0\n";
        return;
    }
    for( int i = 1; i <= n; i++ ){
        for( int j = 0; j <= sum; j++ ){
            d1[i][j] = d[j];
            if( j - a[i] >= 0 ){
                d1[i][j] -= d1[i][j - a[i]];
            }
        }
    }
    if( !d[sum / 2] ){
        cout << "0\n";
        return;
    }
    vector < int > ans;
    for( int i = 1; i <= sum; i++ ){
        bool f = false;
        for( int j = 1; j <= n; j++ ){
            int x = sum - a[j] - i;
            if( x % 2 )f = true;
            if( !d1[j][x / 2] )f = true;
        }
        if( !f )ans.push_back(i);
    }
    cout << (int)ans.size() << "\n";
    for( auto x : ans ){
        cout << x << " ";
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int t = 1;//cin >> t;
    while( t-- ){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7516 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7516 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 8 ms 7672 KB Output is correct
11 Correct 8 ms 7672 KB Output is correct
12 Correct 8 ms 7544 KB Output is correct
13 Correct 8 ms 7544 KB Output is correct
14 Correct 8 ms 7544 KB Output is correct
15 Correct 8 ms 7544 KB Output is correct
16 Correct 8 ms 7672 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 8 ms 7544 KB Output is correct
19 Correct 8 ms 7544 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7516 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 8 ms 7672 KB Output is correct
11 Correct 8 ms 7672 KB Output is correct
12 Correct 8 ms 7544 KB Output is correct
13 Correct 8 ms 7544 KB Output is correct
14 Correct 8 ms 7544 KB Output is correct
15 Correct 8 ms 7544 KB Output is correct
16 Correct 8 ms 7672 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 8 ms 7544 KB Output is correct
19 Correct 8 ms 7544 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8824 KB Output is correct
23 Correct 9 ms 8184 KB Output is correct
24 Correct 12 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 18 ms 11768 KB Output is correct
27 Correct 16 ms 11512 KB Output is correct
28 Correct 16 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10104 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 12 ms 9976 KB Output is correct
33 Correct 17 ms 12024 KB Output is correct
34 Correct 17 ms 12024 KB Output is correct
35 Correct 17 ms 11896 KB Output is correct
36 Correct 12 ms 9976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7516 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 8 ms 7672 KB Output is correct
11 Correct 8 ms 7672 KB Output is correct
12 Correct 8 ms 7544 KB Output is correct
13 Correct 8 ms 7544 KB Output is correct
14 Correct 8 ms 7544 KB Output is correct
15 Correct 8 ms 7544 KB Output is correct
16 Correct 8 ms 7672 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 8 ms 7544 KB Output is correct
19 Correct 8 ms 7544 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8824 KB Output is correct
23 Correct 9 ms 8184 KB Output is correct
24 Correct 12 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 18 ms 11768 KB Output is correct
27 Correct 16 ms 11512 KB Output is correct
28 Correct 16 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10104 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 12 ms 9976 KB Output is correct
33 Correct 17 ms 12024 KB Output is correct
34 Correct 17 ms 12024 KB Output is correct
35 Correct 17 ms 11896 KB Output is correct
36 Correct 12 ms 9976 KB Output is correct
37 Correct 44 ms 24056 KB Output is correct
38 Correct 45 ms 24488 KB Output is correct
39 Correct 169 ms 69084 KB Output is correct
40 Correct 113 ms 43612 KB Output is correct
41 Correct 213 ms 86264 KB Output is correct
42 Correct 82 ms 38648 KB Output is correct
43 Correct 140 ms 62024 KB Output is correct
44 Correct 146 ms 64120 KB Output is correct
45 Correct 146 ms 64888 KB Output is correct
46 Correct 90 ms 42548 KB Output is correct
47 Correct 88 ms 41040 KB Output is correct
48 Correct 160 ms 69496 KB Output is correct
49 Correct 159 ms 69496 KB Output is correct
50 Correct 88 ms 41336 KB Output is correct
51 Correct 18 ms 7544 KB Output is correct
52 Correct 195 ms 83600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7516 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 8 ms 7672 KB Output is correct
11 Correct 8 ms 7672 KB Output is correct
12 Correct 8 ms 7544 KB Output is correct
13 Correct 8 ms 7544 KB Output is correct
14 Correct 8 ms 7544 KB Output is correct
15 Correct 8 ms 7544 KB Output is correct
16 Correct 8 ms 7672 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 8 ms 7544 KB Output is correct
19 Correct 8 ms 7544 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8824 KB Output is correct
23 Correct 9 ms 8184 KB Output is correct
24 Correct 12 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 18 ms 11768 KB Output is correct
27 Correct 16 ms 11512 KB Output is correct
28 Correct 16 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10104 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 12 ms 9976 KB Output is correct
33 Correct 17 ms 12024 KB Output is correct
34 Correct 17 ms 12024 KB Output is correct
35 Correct 17 ms 11896 KB Output is correct
36 Correct 12 ms 9976 KB Output is correct
37 Correct 44 ms 24056 KB Output is correct
38 Correct 45 ms 24488 KB Output is correct
39 Correct 169 ms 69084 KB Output is correct
40 Correct 113 ms 43612 KB Output is correct
41 Correct 213 ms 86264 KB Output is correct
42 Correct 82 ms 38648 KB Output is correct
43 Correct 140 ms 62024 KB Output is correct
44 Correct 146 ms 64120 KB Output is correct
45 Correct 146 ms 64888 KB Output is correct
46 Correct 90 ms 42548 KB Output is correct
47 Correct 88 ms 41040 KB Output is correct
48 Correct 160 ms 69496 KB Output is correct
49 Correct 159 ms 69496 KB Output is correct
50 Correct 88 ms 41336 KB Output is correct
51 Correct 18 ms 7544 KB Output is correct
52 Correct 195 ms 83600 KB Output is correct
53 Correct 143 ms 63152 KB Output is correct
54 Correct 199 ms 86136 KB Output is correct
55 Correct 389 ms 162364 KB Output is correct
56 Correct 180 ms 76568 KB Output is correct
57 Correct 415 ms 170744 KB Output is correct
58 Correct 229 ms 93876 KB Output is correct
59 Correct 270 ms 114936 KB Output is correct
60 Correct 25 ms 7672 KB Output is correct
61 Correct 304 ms 127608 KB Output is correct
62 Correct 307 ms 130020 KB Output is correct
63 Correct 330 ms 140152 KB Output is correct
64 Correct 319 ms 135928 KB Output is correct
65 Correct 159 ms 68856 KB Output is correct
66 Correct 167 ms 73900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7516 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 8 ms 7672 KB Output is correct
11 Correct 8 ms 7672 KB Output is correct
12 Correct 8 ms 7544 KB Output is correct
13 Correct 8 ms 7544 KB Output is correct
14 Correct 8 ms 7544 KB Output is correct
15 Correct 8 ms 7544 KB Output is correct
16 Correct 8 ms 7672 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 8 ms 7544 KB Output is correct
19 Correct 8 ms 7544 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 10 ms 8568 KB Output is correct
22 Correct 10 ms 8824 KB Output is correct
23 Correct 9 ms 8184 KB Output is correct
24 Correct 12 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 18 ms 11768 KB Output is correct
27 Correct 16 ms 11512 KB Output is correct
28 Correct 16 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10104 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 12 ms 9976 KB Output is correct
33 Correct 17 ms 12024 KB Output is correct
34 Correct 17 ms 12024 KB Output is correct
35 Correct 17 ms 11896 KB Output is correct
36 Correct 12 ms 9976 KB Output is correct
37 Correct 44 ms 24056 KB Output is correct
38 Correct 45 ms 24488 KB Output is correct
39 Correct 169 ms 69084 KB Output is correct
40 Correct 113 ms 43612 KB Output is correct
41 Correct 213 ms 86264 KB Output is correct
42 Correct 82 ms 38648 KB Output is correct
43 Correct 140 ms 62024 KB Output is correct
44 Correct 146 ms 64120 KB Output is correct
45 Correct 146 ms 64888 KB Output is correct
46 Correct 90 ms 42548 KB Output is correct
47 Correct 88 ms 41040 KB Output is correct
48 Correct 160 ms 69496 KB Output is correct
49 Correct 159 ms 69496 KB Output is correct
50 Correct 88 ms 41336 KB Output is correct
51 Correct 18 ms 7544 KB Output is correct
52 Correct 195 ms 83600 KB Output is correct
53 Correct 143 ms 63152 KB Output is correct
54 Correct 199 ms 86136 KB Output is correct
55 Correct 389 ms 162364 KB Output is correct
56 Correct 180 ms 76568 KB Output is correct
57 Correct 415 ms 170744 KB Output is correct
58 Correct 229 ms 93876 KB Output is correct
59 Correct 270 ms 114936 KB Output is correct
60 Correct 25 ms 7672 KB Output is correct
61 Correct 304 ms 127608 KB Output is correct
62 Correct 307 ms 130020 KB Output is correct
63 Correct 330 ms 140152 KB Output is correct
64 Correct 319 ms 135928 KB Output is correct
65 Correct 159 ms 68856 KB Output is correct
66 Correct 167 ms 73900 KB Output is correct
67 Correct 316 ms 135928 KB Output is correct
68 Correct 297 ms 252152 KB Output is correct
69 Runtime error 351 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
70 Halted 0 ms 0 KB -