Submission #340098

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

using namespace std;

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;
int d[M+505], dp[M+505];
vi cnt(M+4);

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 sol;
    for (int i = 0; i < n; ++i){
        memset(d, 0, sizeof(d));

        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 12 ms 3308 KB Output is correct
2 Correct 17 ms 3308 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 12 ms 3308 KB Output is correct
5 Correct 33 ms 3308 KB Output is correct
6 Correct 23 ms 3308 KB Output is correct
7 Correct 18 ms 3308 KB Output is correct
8 Correct 33 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3308 KB Output is correct
2 Correct 17 ms 3308 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 12 ms 3308 KB Output is correct
5 Correct 33 ms 3308 KB Output is correct
6 Correct 23 ms 3308 KB Output is correct
7 Correct 18 ms 3308 KB Output is correct
8 Correct 33 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 78 ms 3308 KB Output is correct
11 Correct 79 ms 3308 KB Output is correct
12 Correct 78 ms 3308 KB Output is correct
13 Correct 1 ms 1260 KB Output is correct
14 Correct 74 ms 3308 KB Output is correct
15 Correct 73 ms 3252 KB Output is correct
16 Correct 79 ms 3324 KB Output is correct
17 Correct 48 ms 3308 KB Output is correct
18 Correct 63 ms 3308 KB Output is correct
19 Correct 69 ms 3308 KB Output is correct
20 Correct 78 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3308 KB Output is correct
2 Correct 17 ms 3308 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 12 ms 3308 KB Output is correct
5 Correct 33 ms 3308 KB Output is correct
6 Correct 23 ms 3308 KB Output is correct
7 Correct 18 ms 3308 KB Output is correct
8 Correct 33 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 78 ms 3308 KB Output is correct
11 Correct 79 ms 3308 KB Output is correct
12 Correct 78 ms 3308 KB Output is correct
13 Correct 1 ms 1260 KB Output is correct
14 Correct 74 ms 3308 KB Output is correct
15 Correct 73 ms 3252 KB Output is correct
16 Correct 79 ms 3324 KB Output is correct
17 Correct 48 ms 3308 KB Output is correct
18 Correct 63 ms 3308 KB Output is correct
19 Correct 69 ms 3308 KB Output is correct
20 Correct 78 ms 3308 KB Output is correct
21 Correct 156 ms 3308 KB Output is correct
22 Correct 191 ms 3308 KB Output is correct
23 Correct 130 ms 3308 KB Output is correct
24 Correct 243 ms 3308 KB Output is correct
25 Correct 237 ms 3380 KB Output is correct
26 Correct 253 ms 3308 KB Output is correct
27 Correct 258 ms 3308 KB Output is correct
28 Correct 260 ms 3308 KB Output is correct
29 Correct 259 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 260 ms 3436 KB Output is correct
32 Correct 258 ms 3308 KB Output is correct
33 Correct 258 ms 3308 KB Output is correct
34 Correct 257 ms 3308 KB Output is correct
35 Correct 254 ms 3436 KB Output is correct
36 Correct 249 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3308 KB Output is correct
2 Correct 17 ms 3308 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 12 ms 3308 KB Output is correct
5 Correct 33 ms 3308 KB Output is correct
6 Correct 23 ms 3308 KB Output is correct
7 Correct 18 ms 3308 KB Output is correct
8 Correct 33 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 78 ms 3308 KB Output is correct
11 Correct 79 ms 3308 KB Output is correct
12 Correct 78 ms 3308 KB Output is correct
13 Correct 1 ms 1260 KB Output is correct
14 Correct 74 ms 3308 KB Output is correct
15 Correct 73 ms 3252 KB Output is correct
16 Correct 79 ms 3324 KB Output is correct
17 Correct 48 ms 3308 KB Output is correct
18 Correct 63 ms 3308 KB Output is correct
19 Correct 69 ms 3308 KB Output is correct
20 Correct 78 ms 3308 KB Output is correct
21 Correct 156 ms 3308 KB Output is correct
22 Correct 191 ms 3308 KB Output is correct
23 Correct 130 ms 3308 KB Output is correct
24 Correct 243 ms 3308 KB Output is correct
25 Correct 237 ms 3380 KB Output is correct
26 Correct 253 ms 3308 KB Output is correct
27 Correct 258 ms 3308 KB Output is correct
28 Correct 260 ms 3308 KB Output is correct
29 Correct 259 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 260 ms 3436 KB Output is correct
32 Correct 258 ms 3308 KB Output is correct
33 Correct 258 ms 3308 KB Output is correct
34 Correct 257 ms 3308 KB Output is correct
35 Correct 254 ms 3436 KB Output is correct
36 Correct 249 ms 3308 KB Output is correct
37 Correct 505 ms 3436 KB Output is correct
38 Correct 518 ms 3564 KB Output is correct
39 Correct 623 ms 3308 KB Output is correct
40 Correct 698 ms 3564 KB Output is correct
41 Correct 700 ms 3380 KB Output is correct
42 Correct 645 ms 3564 KB Output is correct
43 Correct 633 ms 3840 KB Output is correct
44 Correct 647 ms 3764 KB Output is correct
45 Correct 627 ms 3820 KB Output is correct
46 Correct 699 ms 3308 KB Output is correct
47 Correct 619 ms 3436 KB Output is correct
48 Correct 645 ms 3636 KB Output is correct
49 Correct 648 ms 3308 KB Output is correct
50 Correct 646 ms 3564 KB Output is correct
51 Correct 1 ms 1260 KB Output is correct
52 Correct 704 ms 3820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3308 KB Output is correct
2 Correct 17 ms 3308 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 12 ms 3308 KB Output is correct
5 Correct 33 ms 3308 KB Output is correct
6 Correct 23 ms 3308 KB Output is correct
7 Correct 18 ms 3308 KB Output is correct
8 Correct 33 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 78 ms 3308 KB Output is correct
11 Correct 79 ms 3308 KB Output is correct
12 Correct 78 ms 3308 KB Output is correct
13 Correct 1 ms 1260 KB Output is correct
14 Correct 74 ms 3308 KB Output is correct
15 Correct 73 ms 3252 KB Output is correct
16 Correct 79 ms 3324 KB Output is correct
17 Correct 48 ms 3308 KB Output is correct
18 Correct 63 ms 3308 KB Output is correct
19 Correct 69 ms 3308 KB Output is correct
20 Correct 78 ms 3308 KB Output is correct
21 Correct 156 ms 3308 KB Output is correct
22 Correct 191 ms 3308 KB Output is correct
23 Correct 130 ms 3308 KB Output is correct
24 Correct 243 ms 3308 KB Output is correct
25 Correct 237 ms 3380 KB Output is correct
26 Correct 253 ms 3308 KB Output is correct
27 Correct 258 ms 3308 KB Output is correct
28 Correct 260 ms 3308 KB Output is correct
29 Correct 259 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 260 ms 3436 KB Output is correct
32 Correct 258 ms 3308 KB Output is correct
33 Correct 258 ms 3308 KB Output is correct
34 Correct 257 ms 3308 KB Output is correct
35 Correct 254 ms 3436 KB Output is correct
36 Correct 249 ms 3308 KB Output is correct
37 Correct 505 ms 3436 KB Output is correct
38 Correct 518 ms 3564 KB Output is correct
39 Correct 623 ms 3308 KB Output is correct
40 Correct 698 ms 3564 KB Output is correct
41 Correct 700 ms 3380 KB Output is correct
42 Correct 645 ms 3564 KB Output is correct
43 Correct 633 ms 3840 KB Output is correct
44 Correct 647 ms 3764 KB Output is correct
45 Correct 627 ms 3820 KB Output is correct
46 Correct 699 ms 3308 KB Output is correct
47 Correct 619 ms 3436 KB Output is correct
48 Correct 645 ms 3636 KB Output is correct
49 Correct 648 ms 3308 KB Output is correct
50 Correct 646 ms 3564 KB Output is correct
51 Correct 1 ms 1260 KB Output is correct
52 Correct 704 ms 3820 KB Output is correct
53 Correct 781 ms 3692 KB Output is correct
54 Correct 908 ms 3820 KB Output is correct
55 Correct 883 ms 4080 KB Output is correct
56 Correct 796 ms 3692 KB Output is correct
57 Correct 929 ms 4032 KB Output is correct
58 Correct 914 ms 3716 KB Output is correct
59 Correct 883 ms 3720 KB Output is correct
60 Correct 1 ms 1260 KB Output is correct
61 Correct 910 ms 3952 KB Output is correct
62 Correct 839 ms 3896 KB Output is correct
63 Correct 840 ms 3952 KB Output is correct
64 Correct 822 ms 3952 KB Output is correct
65 Correct 808 ms 3436 KB Output is correct
66 Correct 797 ms 3332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 3308 KB Output is correct
2 Correct 17 ms 3308 KB Output is correct
3 Correct 4 ms 2284 KB Output is correct
4 Correct 12 ms 3308 KB Output is correct
5 Correct 33 ms 3308 KB Output is correct
6 Correct 23 ms 3308 KB Output is correct
7 Correct 18 ms 3308 KB Output is correct
8 Correct 33 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 78 ms 3308 KB Output is correct
11 Correct 79 ms 3308 KB Output is correct
12 Correct 78 ms 3308 KB Output is correct
13 Correct 1 ms 1260 KB Output is correct
14 Correct 74 ms 3308 KB Output is correct
15 Correct 73 ms 3252 KB Output is correct
16 Correct 79 ms 3324 KB Output is correct
17 Correct 48 ms 3308 KB Output is correct
18 Correct 63 ms 3308 KB Output is correct
19 Correct 69 ms 3308 KB Output is correct
20 Correct 78 ms 3308 KB Output is correct
21 Correct 156 ms 3308 KB Output is correct
22 Correct 191 ms 3308 KB Output is correct
23 Correct 130 ms 3308 KB Output is correct
24 Correct 243 ms 3308 KB Output is correct
25 Correct 237 ms 3380 KB Output is correct
26 Correct 253 ms 3308 KB Output is correct
27 Correct 258 ms 3308 KB Output is correct
28 Correct 260 ms 3308 KB Output is correct
29 Correct 259 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 260 ms 3436 KB Output is correct
32 Correct 258 ms 3308 KB Output is correct
33 Correct 258 ms 3308 KB Output is correct
34 Correct 257 ms 3308 KB Output is correct
35 Correct 254 ms 3436 KB Output is correct
36 Correct 249 ms 3308 KB Output is correct
37 Correct 505 ms 3436 KB Output is correct
38 Correct 518 ms 3564 KB Output is correct
39 Correct 623 ms 3308 KB Output is correct
40 Correct 698 ms 3564 KB Output is correct
41 Correct 700 ms 3380 KB Output is correct
42 Correct 645 ms 3564 KB Output is correct
43 Correct 633 ms 3840 KB Output is correct
44 Correct 647 ms 3764 KB Output is correct
45 Correct 627 ms 3820 KB Output is correct
46 Correct 699 ms 3308 KB Output is correct
47 Correct 619 ms 3436 KB Output is correct
48 Correct 645 ms 3636 KB Output is correct
49 Correct 648 ms 3308 KB Output is correct
50 Correct 646 ms 3564 KB Output is correct
51 Correct 1 ms 1260 KB Output is correct
52 Correct 704 ms 3820 KB Output is correct
53 Correct 781 ms 3692 KB Output is correct
54 Correct 908 ms 3820 KB Output is correct
55 Correct 883 ms 4080 KB Output is correct
56 Correct 796 ms 3692 KB Output is correct
57 Correct 929 ms 4032 KB Output is correct
58 Correct 914 ms 3716 KB Output is correct
59 Correct 883 ms 3720 KB Output is correct
60 Correct 1 ms 1260 KB Output is correct
61 Correct 910 ms 3952 KB Output is correct
62 Correct 839 ms 3896 KB Output is correct
63 Correct 840 ms 3952 KB Output is correct
64 Correct 822 ms 3952 KB Output is correct
65 Correct 808 ms 3436 KB Output is correct
66 Correct 797 ms 3332 KB Output is correct
67 Execution timed out 1051 ms 3896 KB Time limit exceeded
68 Halted 0 ms 0 KB -