Submission #167691

# Submission time Handle Problem Language Result Execution time Memory
167691 2019-12-09T16:27:26 Z muhammad_hokimiyon Bootfall (IZhO17_bootfall) C++14
65 / 100
408 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 7544 KB Output is correct
9 Correct 8 ms 7416 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 7544 KB Output is correct
9 Correct 8 ms 7416 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 7672 KB Output is correct
13 Correct 8 ms 7608 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 7548 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 7544 KB Output is correct
9 Correct 8 ms 7416 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 7672 KB Output is correct
13 Correct 8 ms 7608 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 7548 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 11 ms 8696 KB Output is correct
22 Correct 11 ms 8824 KB Output is correct
23 Correct 10 ms 8184 KB Output is correct
24 Correct 15 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 17 ms 11768 KB Output is correct
27 Correct 17 ms 11640 KB Output is correct
28 Correct 21 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10108 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 13 ms 9976 KB Output is correct
33 Correct 16 ms 12024 KB Output is correct
34 Correct 17 ms 11896 KB Output is correct
35 Correct 21 ms 11896 KB Output is correct
36 Correct 15 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 7544 KB Output is correct
9 Correct 8 ms 7416 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 7672 KB Output is correct
13 Correct 8 ms 7608 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 7548 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 11 ms 8696 KB Output is correct
22 Correct 11 ms 8824 KB Output is correct
23 Correct 10 ms 8184 KB Output is correct
24 Correct 15 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 17 ms 11768 KB Output is correct
27 Correct 17 ms 11640 KB Output is correct
28 Correct 21 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10108 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 13 ms 9976 KB Output is correct
33 Correct 16 ms 12024 KB Output is correct
34 Correct 17 ms 11896 KB Output is correct
35 Correct 21 ms 11896 KB Output is correct
36 Correct 15 ms 9976 KB Output is correct
37 Correct 47 ms 24060 KB Output is correct
38 Correct 47 ms 24412 KB Output is correct
39 Correct 166 ms 68984 KB Output is correct
40 Correct 97 ms 43624 KB Output is correct
41 Correct 214 ms 86264 KB Output is correct
42 Correct 90 ms 38664 KB Output is correct
43 Correct 141 ms 62044 KB Output is correct
44 Correct 146 ms 63864 KB Output is correct
45 Correct 148 ms 64760 KB Output is correct
46 Correct 93 ms 42744 KB Output is correct
47 Correct 90 ms 41124 KB Output is correct
48 Correct 164 ms 69368 KB Output is correct
49 Correct 160 ms 69608 KB Output is correct
50 Correct 88 ms 41336 KB Output is correct
51 Correct 14 ms 7548 KB Output is correct
52 Correct 197 ms 83576 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 7544 KB Output is correct
9 Correct 8 ms 7416 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 7672 KB Output is correct
13 Correct 8 ms 7608 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 7548 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 11 ms 8696 KB Output is correct
22 Correct 11 ms 8824 KB Output is correct
23 Correct 10 ms 8184 KB Output is correct
24 Correct 15 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 17 ms 11768 KB Output is correct
27 Correct 17 ms 11640 KB Output is correct
28 Correct 21 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10108 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 13 ms 9976 KB Output is correct
33 Correct 16 ms 12024 KB Output is correct
34 Correct 17 ms 11896 KB Output is correct
35 Correct 21 ms 11896 KB Output is correct
36 Correct 15 ms 9976 KB Output is correct
37 Correct 47 ms 24060 KB Output is correct
38 Correct 47 ms 24412 KB Output is correct
39 Correct 166 ms 68984 KB Output is correct
40 Correct 97 ms 43624 KB Output is correct
41 Correct 214 ms 86264 KB Output is correct
42 Correct 90 ms 38664 KB Output is correct
43 Correct 141 ms 62044 KB Output is correct
44 Correct 146 ms 63864 KB Output is correct
45 Correct 148 ms 64760 KB Output is correct
46 Correct 93 ms 42744 KB Output is correct
47 Correct 90 ms 41124 KB Output is correct
48 Correct 164 ms 69368 KB Output is correct
49 Correct 160 ms 69608 KB Output is correct
50 Correct 88 ms 41336 KB Output is correct
51 Correct 14 ms 7548 KB Output is correct
52 Correct 197 ms 83576 KB Output is correct
53 Correct 142 ms 63224 KB Output is correct
54 Correct 198 ms 86136 KB Output is correct
55 Correct 393 ms 162372 KB Output is correct
56 Correct 181 ms 76584 KB Output is correct
57 Correct 408 ms 170916 KB Output is correct
58 Correct 222 ms 93816 KB Output is correct
59 Correct 282 ms 114936 KB Output is correct
60 Correct 26 ms 7672 KB Output is correct
61 Correct 303 ms 127608 KB Output is correct
62 Correct 307 ms 130040 KB Output is correct
63 Correct 356 ms 140152 KB Output is correct
64 Correct 318 ms 135796 KB Output is correct
65 Correct 160 ms 68984 KB Output is correct
66 Correct 167 ms 74084 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 7544 KB Output is correct
9 Correct 8 ms 7416 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 7672 KB Output is correct
13 Correct 8 ms 7608 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 7548 KB Output is correct
20 Correct 8 ms 7672 KB Output is correct
21 Correct 11 ms 8696 KB Output is correct
22 Correct 11 ms 8824 KB Output is correct
23 Correct 10 ms 8184 KB Output is correct
24 Correct 15 ms 9720 KB Output is correct
25 Correct 16 ms 11384 KB Output is correct
26 Correct 17 ms 11768 KB Output is correct
27 Correct 17 ms 11640 KB Output is correct
28 Correct 21 ms 11768 KB Output is correct
29 Correct 16 ms 11896 KB Output is correct
30 Correct 13 ms 10108 KB Output is correct
31 Correct 15 ms 11000 KB Output is correct
32 Correct 13 ms 9976 KB Output is correct
33 Correct 16 ms 12024 KB Output is correct
34 Correct 17 ms 11896 KB Output is correct
35 Correct 21 ms 11896 KB Output is correct
36 Correct 15 ms 9976 KB Output is correct
37 Correct 47 ms 24060 KB Output is correct
38 Correct 47 ms 24412 KB Output is correct
39 Correct 166 ms 68984 KB Output is correct
40 Correct 97 ms 43624 KB Output is correct
41 Correct 214 ms 86264 KB Output is correct
42 Correct 90 ms 38664 KB Output is correct
43 Correct 141 ms 62044 KB Output is correct
44 Correct 146 ms 63864 KB Output is correct
45 Correct 148 ms 64760 KB Output is correct
46 Correct 93 ms 42744 KB Output is correct
47 Correct 90 ms 41124 KB Output is correct
48 Correct 164 ms 69368 KB Output is correct
49 Correct 160 ms 69608 KB Output is correct
50 Correct 88 ms 41336 KB Output is correct
51 Correct 14 ms 7548 KB Output is correct
52 Correct 197 ms 83576 KB Output is correct
53 Correct 142 ms 63224 KB Output is correct
54 Correct 198 ms 86136 KB Output is correct
55 Correct 393 ms 162372 KB Output is correct
56 Correct 181 ms 76584 KB Output is correct
57 Correct 408 ms 170916 KB Output is correct
58 Correct 222 ms 93816 KB Output is correct
59 Correct 282 ms 114936 KB Output is correct
60 Correct 26 ms 7672 KB Output is correct
61 Correct 303 ms 127608 KB Output is correct
62 Correct 307 ms 130040 KB Output is correct
63 Correct 356 ms 140152 KB Output is correct
64 Correct 318 ms 135796 KB Output is correct
65 Correct 160 ms 68984 KB Output is correct
66 Correct 167 ms 74084 KB Output is correct
67 Correct 307 ms 135772 KB Output is correct
68 Correct 297 ms 252252 KB Output is correct
69 Runtime error 354 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
70 Halted 0 ms 0 KB -