Submission #340095

# Submission time Handle Problem Language Result Execution time Memory
340095 2020-12-26T21:55:34 Z Sprdalo Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 7144 KB
#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

void no(){
    cout << "0\n";
    exit(0);
}

const int M = 250000;
vi dp(M+510);

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    int n;
    cin >> n;

    vi a(n);
    int suma = 0;
    bool pp = 0, np = 0;
    for (auto& i : a){
        cin >> i;
        suma += i;

        if (i%2)
            np=1;
        else
            pp=1;
    }

    if ((pp && np) || suma%2) no();

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

    if (!dp[suma/2]) no();

    vi d(M+505, 0), cnt(M+505, 0), sol;
    for (int i = 0; i < n; ++i){
        fill(d.begin(), d.end(), 0);

        for (int j = 0; j <= M; ++j){
            d[j] += dp[j];
            d[j+a[i]] -= d[j];
        }

        for (int j = 0; j <= M; ++j){
            if ((suma-a[i]+j)%2 == 0 && suma-a[i]-j>=0 && d[(suma-a[i]-j)/2]){
                ++cnt[j];
                if (cnt[j] == n)
                    sol.push_back(j);
            }
        }
    }

    sort(sol.begin(), sol.end());
    cout << (int)sol.size() << '\n';

    for (auto& i : sol)
        cout << i << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6252 KB Output is correct
2 Correct 19 ms 6252 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 14 ms 6252 KB Output is correct
5 Correct 36 ms 6400 KB Output is correct
6 Correct 24 ms 6252 KB Output is correct
7 Correct 19 ms 6272 KB Output is correct
8 Correct 34 ms 6252 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6252 KB Output is correct
2 Correct 19 ms 6252 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 14 ms 6252 KB Output is correct
5 Correct 36 ms 6400 KB Output is correct
6 Correct 24 ms 6252 KB Output is correct
7 Correct 19 ms 6272 KB Output is correct
8 Correct 34 ms 6252 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 80 ms 6180 KB Output is correct
11 Correct 80 ms 6252 KB Output is correct
12 Correct 80 ms 6252 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 74 ms 6252 KB Output is correct
15 Correct 74 ms 6272 KB Output is correct
16 Correct 81 ms 6380 KB Output is correct
17 Correct 49 ms 6252 KB Output is correct
18 Correct 63 ms 6272 KB Output is correct
19 Correct 69 ms 6252 KB Output is correct
20 Correct 80 ms 6252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6252 KB Output is correct
2 Correct 19 ms 6252 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 14 ms 6252 KB Output is correct
5 Correct 36 ms 6400 KB Output is correct
6 Correct 24 ms 6252 KB Output is correct
7 Correct 19 ms 6272 KB Output is correct
8 Correct 34 ms 6252 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 80 ms 6180 KB Output is correct
11 Correct 80 ms 6252 KB Output is correct
12 Correct 80 ms 6252 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 74 ms 6252 KB Output is correct
15 Correct 74 ms 6272 KB Output is correct
16 Correct 81 ms 6380 KB Output is correct
17 Correct 49 ms 6252 KB Output is correct
18 Correct 63 ms 6272 KB Output is correct
19 Correct 69 ms 6252 KB Output is correct
20 Correct 80 ms 6252 KB Output is correct
21 Correct 145 ms 6252 KB Output is correct
22 Correct 195 ms 6412 KB Output is correct
23 Correct 130 ms 6252 KB Output is correct
24 Correct 245 ms 6252 KB Output is correct
25 Correct 243 ms 6252 KB Output is correct
26 Correct 226 ms 6252 KB Output is correct
27 Correct 260 ms 6252 KB Output is correct
28 Correct 237 ms 6252 KB Output is correct
29 Correct 257 ms 6252 KB Output is correct
30 Correct 2 ms 2284 KB Output is correct
31 Correct 256 ms 6252 KB Output is correct
32 Correct 257 ms 6380 KB Output is correct
33 Correct 257 ms 6380 KB Output is correct
34 Correct 258 ms 6252 KB Output is correct
35 Correct 263 ms 6284 KB Output is correct
36 Correct 256 ms 6252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6252 KB Output is correct
2 Correct 19 ms 6252 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 14 ms 6252 KB Output is correct
5 Correct 36 ms 6400 KB Output is correct
6 Correct 24 ms 6252 KB Output is correct
7 Correct 19 ms 6272 KB Output is correct
8 Correct 34 ms 6252 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 80 ms 6180 KB Output is correct
11 Correct 80 ms 6252 KB Output is correct
12 Correct 80 ms 6252 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 74 ms 6252 KB Output is correct
15 Correct 74 ms 6272 KB Output is correct
16 Correct 81 ms 6380 KB Output is correct
17 Correct 49 ms 6252 KB Output is correct
18 Correct 63 ms 6272 KB Output is correct
19 Correct 69 ms 6252 KB Output is correct
20 Correct 80 ms 6252 KB Output is correct
21 Correct 145 ms 6252 KB Output is correct
22 Correct 195 ms 6412 KB Output is correct
23 Correct 130 ms 6252 KB Output is correct
24 Correct 245 ms 6252 KB Output is correct
25 Correct 243 ms 6252 KB Output is correct
26 Correct 226 ms 6252 KB Output is correct
27 Correct 260 ms 6252 KB Output is correct
28 Correct 237 ms 6252 KB Output is correct
29 Correct 257 ms 6252 KB Output is correct
30 Correct 2 ms 2284 KB Output is correct
31 Correct 256 ms 6252 KB Output is correct
32 Correct 257 ms 6380 KB Output is correct
33 Correct 257 ms 6380 KB Output is correct
34 Correct 258 ms 6252 KB Output is correct
35 Correct 263 ms 6284 KB Output is correct
36 Correct 256 ms 6252 KB Output is correct
37 Correct 513 ms 6508 KB Output is correct
38 Correct 516 ms 6636 KB Output is correct
39 Correct 642 ms 6252 KB Output is correct
40 Correct 696 ms 6636 KB Output is correct
41 Correct 694 ms 6380 KB Output is correct
42 Correct 642 ms 6636 KB Output is correct
43 Correct 630 ms 6764 KB Output is correct
44 Correct 627 ms 6764 KB Output is correct
45 Correct 648 ms 6764 KB Output is correct
46 Correct 688 ms 6456 KB Output is correct
47 Correct 641 ms 6636 KB Output is correct
48 Correct 645 ms 6636 KB Output is correct
49 Correct 642 ms 6380 KB Output is correct
50 Correct 639 ms 6636 KB Output is correct
51 Correct 2 ms 2284 KB Output is correct
52 Correct 705 ms 6764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6252 KB Output is correct
2 Correct 19 ms 6252 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 14 ms 6252 KB Output is correct
5 Correct 36 ms 6400 KB Output is correct
6 Correct 24 ms 6252 KB Output is correct
7 Correct 19 ms 6272 KB Output is correct
8 Correct 34 ms 6252 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 80 ms 6180 KB Output is correct
11 Correct 80 ms 6252 KB Output is correct
12 Correct 80 ms 6252 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 74 ms 6252 KB Output is correct
15 Correct 74 ms 6272 KB Output is correct
16 Correct 81 ms 6380 KB Output is correct
17 Correct 49 ms 6252 KB Output is correct
18 Correct 63 ms 6272 KB Output is correct
19 Correct 69 ms 6252 KB Output is correct
20 Correct 80 ms 6252 KB Output is correct
21 Correct 145 ms 6252 KB Output is correct
22 Correct 195 ms 6412 KB Output is correct
23 Correct 130 ms 6252 KB Output is correct
24 Correct 245 ms 6252 KB Output is correct
25 Correct 243 ms 6252 KB Output is correct
26 Correct 226 ms 6252 KB Output is correct
27 Correct 260 ms 6252 KB Output is correct
28 Correct 237 ms 6252 KB Output is correct
29 Correct 257 ms 6252 KB Output is correct
30 Correct 2 ms 2284 KB Output is correct
31 Correct 256 ms 6252 KB Output is correct
32 Correct 257 ms 6380 KB Output is correct
33 Correct 257 ms 6380 KB Output is correct
34 Correct 258 ms 6252 KB Output is correct
35 Correct 263 ms 6284 KB Output is correct
36 Correct 256 ms 6252 KB Output is correct
37 Correct 513 ms 6508 KB Output is correct
38 Correct 516 ms 6636 KB Output is correct
39 Correct 642 ms 6252 KB Output is correct
40 Correct 696 ms 6636 KB Output is correct
41 Correct 694 ms 6380 KB Output is correct
42 Correct 642 ms 6636 KB Output is correct
43 Correct 630 ms 6764 KB Output is correct
44 Correct 627 ms 6764 KB Output is correct
45 Correct 648 ms 6764 KB Output is correct
46 Correct 688 ms 6456 KB Output is correct
47 Correct 641 ms 6636 KB Output is correct
48 Correct 645 ms 6636 KB Output is correct
49 Correct 642 ms 6380 KB Output is correct
50 Correct 639 ms 6636 KB Output is correct
51 Correct 2 ms 2284 KB Output is correct
52 Correct 705 ms 6764 KB Output is correct
53 Correct 772 ms 6636 KB Output is correct
54 Correct 908 ms 6764 KB Output is correct
55 Correct 903 ms 7016 KB Output is correct
56 Correct 769 ms 6840 KB Output is correct
57 Correct 923 ms 7092 KB Output is correct
58 Correct 905 ms 6764 KB Output is correct
59 Correct 909 ms 6892 KB Output is correct
60 Correct 2 ms 2284 KB Output is correct
61 Correct 908 ms 6976 KB Output is correct
62 Correct 821 ms 7016 KB Output is correct
63 Correct 809 ms 7104 KB Output is correct
64 Correct 817 ms 7144 KB Output is correct
65 Correct 811 ms 6252 KB Output is correct
66 Correct 797 ms 6508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6252 KB Output is correct
2 Correct 19 ms 6252 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 14 ms 6252 KB Output is correct
5 Correct 36 ms 6400 KB Output is correct
6 Correct 24 ms 6252 KB Output is correct
7 Correct 19 ms 6272 KB Output is correct
8 Correct 34 ms 6252 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 80 ms 6180 KB Output is correct
11 Correct 80 ms 6252 KB Output is correct
12 Correct 80 ms 6252 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 74 ms 6252 KB Output is correct
15 Correct 74 ms 6272 KB Output is correct
16 Correct 81 ms 6380 KB Output is correct
17 Correct 49 ms 6252 KB Output is correct
18 Correct 63 ms 6272 KB Output is correct
19 Correct 69 ms 6252 KB Output is correct
20 Correct 80 ms 6252 KB Output is correct
21 Correct 145 ms 6252 KB Output is correct
22 Correct 195 ms 6412 KB Output is correct
23 Correct 130 ms 6252 KB Output is correct
24 Correct 245 ms 6252 KB Output is correct
25 Correct 243 ms 6252 KB Output is correct
26 Correct 226 ms 6252 KB Output is correct
27 Correct 260 ms 6252 KB Output is correct
28 Correct 237 ms 6252 KB Output is correct
29 Correct 257 ms 6252 KB Output is correct
30 Correct 2 ms 2284 KB Output is correct
31 Correct 256 ms 6252 KB Output is correct
32 Correct 257 ms 6380 KB Output is correct
33 Correct 257 ms 6380 KB Output is correct
34 Correct 258 ms 6252 KB Output is correct
35 Correct 263 ms 6284 KB Output is correct
36 Correct 256 ms 6252 KB Output is correct
37 Correct 513 ms 6508 KB Output is correct
38 Correct 516 ms 6636 KB Output is correct
39 Correct 642 ms 6252 KB Output is correct
40 Correct 696 ms 6636 KB Output is correct
41 Correct 694 ms 6380 KB Output is correct
42 Correct 642 ms 6636 KB Output is correct
43 Correct 630 ms 6764 KB Output is correct
44 Correct 627 ms 6764 KB Output is correct
45 Correct 648 ms 6764 KB Output is correct
46 Correct 688 ms 6456 KB Output is correct
47 Correct 641 ms 6636 KB Output is correct
48 Correct 645 ms 6636 KB Output is correct
49 Correct 642 ms 6380 KB Output is correct
50 Correct 639 ms 6636 KB Output is correct
51 Correct 2 ms 2284 KB Output is correct
52 Correct 705 ms 6764 KB Output is correct
53 Correct 772 ms 6636 KB Output is correct
54 Correct 908 ms 6764 KB Output is correct
55 Correct 903 ms 7016 KB Output is correct
56 Correct 769 ms 6840 KB Output is correct
57 Correct 923 ms 7092 KB Output is correct
58 Correct 905 ms 6764 KB Output is correct
59 Correct 909 ms 6892 KB Output is correct
60 Correct 2 ms 2284 KB Output is correct
61 Correct 908 ms 6976 KB Output is correct
62 Correct 821 ms 7016 KB Output is correct
63 Correct 809 ms 7104 KB Output is correct
64 Correct 817 ms 7144 KB Output is correct
65 Correct 811 ms 6252 KB Output is correct
66 Correct 797 ms 6508 KB Output is correct
67 Execution timed out 1037 ms 6892 KB Time limit exceeded
68 Halted 0 ms 0 KB -