Submission #167661

# Submission time Handle Problem Language Result Execution time Memory
167661 2019-12-09T10:08:49 Z Rakhmand Bootfall (IZhO17_bootfall) C++14
100 / 100
724 ms 243956 KB
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)
 
const int MXN = 4e5 + 200;
const long long MNN = 4e2 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;
 
int n, k, a[MXN], cnt, dp[260000], del[510][126000];
int sum = 0;
vector<int> v;

void precalc(){
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = sum; j >= 0; j--){
            if(j - a[i] >= 0){
                dp[j] += dp[j - a[i]];
            }
        }
    }
}

void add(){
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= sum / 2; j++){
            del[i][j] = dp[j];
            if(j - a[i] >= 0){
                del[i][j] -= del[i][j - a[i]];
            }
        }
    }
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
        cnt += a[i] % 2;
    }
    if(sum % 2 == 1) no_answer;
    if(cnt != 0 && cnt != n) no_answer;
    precalc();
    if(dp[sum / 2] == 0) no_answer;
    add();
    for(int j = a[1] % 2; j <= sum; j += 2){
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            int left = (sum - a[i] - j) / 2;
            if(del[i][left]) cnt++;
        }
        if(cnt == n) v.pb(j);
    }
    cout << v.size() << nl;
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << ' ';
    }
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:102:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); i++){
                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1272 KB Output is correct
23 Correct 3 ms 916 KB Output is correct
24 Correct 4 ms 1784 KB Output is correct
25 Correct 6 ms 2680 KB Output is correct
26 Correct 7 ms 2808 KB Output is correct
27 Correct 6 ms 2552 KB Output is correct
28 Correct 6 ms 2684 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 6 ms 2424 KB Output is correct
32 Correct 4 ms 1784 KB Output is correct
33 Correct 6 ms 2808 KB Output is correct
34 Correct 6 ms 2808 KB Output is correct
35 Correct 6 ms 2808 KB Output is correct
36 Correct 5 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1272 KB Output is correct
23 Correct 3 ms 916 KB Output is correct
24 Correct 4 ms 1784 KB Output is correct
25 Correct 6 ms 2680 KB Output is correct
26 Correct 7 ms 2808 KB Output is correct
27 Correct 6 ms 2552 KB Output is correct
28 Correct 6 ms 2684 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 6 ms 2424 KB Output is correct
32 Correct 4 ms 1784 KB Output is correct
33 Correct 6 ms 2808 KB Output is correct
34 Correct 6 ms 2808 KB Output is correct
35 Correct 6 ms 2808 KB Output is correct
36 Correct 5 ms 1784 KB Output is correct
37 Correct 21 ms 9208 KB Output is correct
38 Correct 22 ms 9336 KB Output is correct
39 Correct 68 ms 31808 KB Output is correct
40 Correct 54 ms 19192 KB Output is correct
41 Correct 86 ms 40440 KB Output is correct
42 Correct 48 ms 16632 KB Output is correct
43 Correct 86 ms 28380 KB Output is correct
44 Correct 87 ms 29432 KB Output is correct
45 Correct 92 ms 29816 KB Output is correct
46 Correct 52 ms 18424 KB Output is correct
47 Correct 51 ms 17784 KB Output is correct
48 Correct 82 ms 31992 KB Output is correct
49 Correct 77 ms 31992 KB Output is correct
50 Correct 49 ms 17956 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 115 ms 39288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1272 KB Output is correct
23 Correct 3 ms 916 KB Output is correct
24 Correct 4 ms 1784 KB Output is correct
25 Correct 6 ms 2680 KB Output is correct
26 Correct 7 ms 2808 KB Output is correct
27 Correct 6 ms 2552 KB Output is correct
28 Correct 6 ms 2684 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 6 ms 2424 KB Output is correct
32 Correct 4 ms 1784 KB Output is correct
33 Correct 6 ms 2808 KB Output is correct
34 Correct 6 ms 2808 KB Output is correct
35 Correct 6 ms 2808 KB Output is correct
36 Correct 5 ms 1784 KB Output is correct
37 Correct 21 ms 9208 KB Output is correct
38 Correct 22 ms 9336 KB Output is correct
39 Correct 68 ms 31808 KB Output is correct
40 Correct 54 ms 19192 KB Output is correct
41 Correct 86 ms 40440 KB Output is correct
42 Correct 48 ms 16632 KB Output is correct
43 Correct 86 ms 28380 KB Output is correct
44 Correct 87 ms 29432 KB Output is correct
45 Correct 92 ms 29816 KB Output is correct
46 Correct 52 ms 18424 KB Output is correct
47 Correct 51 ms 17784 KB Output is correct
48 Correct 82 ms 31992 KB Output is correct
49 Correct 77 ms 31992 KB Output is correct
50 Correct 49 ms 17956 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 115 ms 39288 KB Output is correct
53 Correct 86 ms 29132 KB Output is correct
54 Correct 123 ms 40640 KB Output is correct
55 Correct 233 ms 78964 KB Output is correct
56 Correct 107 ms 35808 KB Output is correct
57 Correct 252 ms 83232 KB Output is correct
58 Correct 133 ms 44536 KB Output is correct
59 Correct 168 ms 55160 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 191 ms 61532 KB Output is correct
62 Correct 190 ms 62708 KB Output is correct
63 Correct 205 ms 67784 KB Output is correct
64 Correct 199 ms 65580 KB Output is correct
65 Correct 79 ms 31800 KB Output is correct
66 Correct 99 ms 34340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 476 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1272 KB Output is correct
23 Correct 3 ms 916 KB Output is correct
24 Correct 4 ms 1784 KB Output is correct
25 Correct 6 ms 2680 KB Output is correct
26 Correct 7 ms 2808 KB Output is correct
27 Correct 6 ms 2552 KB Output is correct
28 Correct 6 ms 2684 KB Output is correct
29 Correct 6 ms 2808 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 6 ms 2424 KB Output is correct
32 Correct 4 ms 1784 KB Output is correct
33 Correct 6 ms 2808 KB Output is correct
34 Correct 6 ms 2808 KB Output is correct
35 Correct 6 ms 2808 KB Output is correct
36 Correct 5 ms 1784 KB Output is correct
37 Correct 21 ms 9208 KB Output is correct
38 Correct 22 ms 9336 KB Output is correct
39 Correct 68 ms 31808 KB Output is correct
40 Correct 54 ms 19192 KB Output is correct
41 Correct 86 ms 40440 KB Output is correct
42 Correct 48 ms 16632 KB Output is correct
43 Correct 86 ms 28380 KB Output is correct
44 Correct 87 ms 29432 KB Output is correct
45 Correct 92 ms 29816 KB Output is correct
46 Correct 52 ms 18424 KB Output is correct
47 Correct 51 ms 17784 KB Output is correct
48 Correct 82 ms 31992 KB Output is correct
49 Correct 77 ms 31992 KB Output is correct
50 Correct 49 ms 17956 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 115 ms 39288 KB Output is correct
53 Correct 86 ms 29132 KB Output is correct
54 Correct 123 ms 40640 KB Output is correct
55 Correct 233 ms 78964 KB Output is correct
56 Correct 107 ms 35808 KB Output is correct
57 Correct 252 ms 83232 KB Output is correct
58 Correct 133 ms 44536 KB Output is correct
59 Correct 168 ms 55160 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 191 ms 61532 KB Output is correct
62 Correct 190 ms 62708 KB Output is correct
63 Correct 205 ms 67784 KB Output is correct
64 Correct 199 ms 65580 KB Output is correct
65 Correct 79 ms 31800 KB Output is correct
66 Correct 99 ms 34340 KB Output is correct
67 Correct 185 ms 65628 KB Output is correct
68 Correct 51 ms 888 KB Output is correct
69 Correct 654 ms 211700 KB Output is correct
70 Correct 432 ms 129324 KB Output is correct
71 Correct 393 ms 125448 KB Output is correct
72 Correct 2 ms 376 KB Output is correct
73 Correct 2 ms 376 KB Output is correct
74 Correct 698 ms 222936 KB Output is correct
75 Correct 536 ms 173944 KB Output is correct
76 Correct 724 ms 243956 KB Output is correct
77 Correct 724 ms 236924 KB Output is correct