Submission #340099

# Submission time Handle Problem Language Result Execution time Memory
340099 2020-12-26T22:01:40 Z Sprdalo Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 4228 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];
            }
        }
    }

    for (int i = 1; i <= M; ++i)
        if (cnt[i] == n)
            sol.push_back(i);

    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 30 ms 3308 KB Output is correct
6 Correct 21 ms 3308 KB Output is correct
7 Correct 17 ms 3308 KB Output is correct
8 Correct 30 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 30 ms 3308 KB Output is correct
6 Correct 21 ms 3308 KB Output is correct
7 Correct 17 ms 3308 KB Output is correct
8 Correct 30 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 69 ms 3308 KB Output is correct
11 Correct 68 ms 3436 KB Output is correct
12 Correct 68 ms 3308 KB Output is correct
13 Correct 2 ms 1260 KB Output is correct
14 Correct 68 ms 3308 KB Output is correct
15 Correct 66 ms 3328 KB Output is correct
16 Correct 70 ms 3308 KB Output is correct
17 Correct 46 ms 3308 KB Output is correct
18 Correct 57 ms 3308 KB Output is correct
19 Correct 62 ms 3308 KB Output is correct
20 Correct 70 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 30 ms 3308 KB Output is correct
6 Correct 21 ms 3308 KB Output is correct
7 Correct 17 ms 3308 KB Output is correct
8 Correct 30 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 69 ms 3308 KB Output is correct
11 Correct 68 ms 3436 KB Output is correct
12 Correct 68 ms 3308 KB Output is correct
13 Correct 2 ms 1260 KB Output is correct
14 Correct 68 ms 3308 KB Output is correct
15 Correct 66 ms 3328 KB Output is correct
16 Correct 70 ms 3308 KB Output is correct
17 Correct 46 ms 3308 KB Output is correct
18 Correct 57 ms 3308 KB Output is correct
19 Correct 62 ms 3308 KB Output is correct
20 Correct 70 ms 3308 KB Output is correct
21 Correct 148 ms 3308 KB Output is correct
22 Correct 172 ms 3436 KB Output is correct
23 Correct 118 ms 3332 KB Output is correct
24 Correct 216 ms 3308 KB Output is correct
25 Correct 221 ms 3308 KB Output is correct
26 Correct 231 ms 3308 KB Output is correct
27 Correct 229 ms 3308 KB Output is correct
28 Correct 232 ms 3308 KB Output is correct
29 Correct 232 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 230 ms 3308 KB Output is correct
32 Correct 232 ms 3436 KB Output is correct
33 Correct 229 ms 3308 KB Output is correct
34 Correct 229 ms 3308 KB Output is correct
35 Correct 228 ms 3308 KB Output is correct
36 Correct 230 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 30 ms 3308 KB Output is correct
6 Correct 21 ms 3308 KB Output is correct
7 Correct 17 ms 3308 KB Output is correct
8 Correct 30 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 69 ms 3308 KB Output is correct
11 Correct 68 ms 3436 KB Output is correct
12 Correct 68 ms 3308 KB Output is correct
13 Correct 2 ms 1260 KB Output is correct
14 Correct 68 ms 3308 KB Output is correct
15 Correct 66 ms 3328 KB Output is correct
16 Correct 70 ms 3308 KB Output is correct
17 Correct 46 ms 3308 KB Output is correct
18 Correct 57 ms 3308 KB Output is correct
19 Correct 62 ms 3308 KB Output is correct
20 Correct 70 ms 3308 KB Output is correct
21 Correct 148 ms 3308 KB Output is correct
22 Correct 172 ms 3436 KB Output is correct
23 Correct 118 ms 3332 KB Output is correct
24 Correct 216 ms 3308 KB Output is correct
25 Correct 221 ms 3308 KB Output is correct
26 Correct 231 ms 3308 KB Output is correct
27 Correct 229 ms 3308 KB Output is correct
28 Correct 232 ms 3308 KB Output is correct
29 Correct 232 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 230 ms 3308 KB Output is correct
32 Correct 232 ms 3436 KB Output is correct
33 Correct 229 ms 3308 KB Output is correct
34 Correct 229 ms 3308 KB Output is correct
35 Correct 228 ms 3308 KB Output is correct
36 Correct 230 ms 3308 KB Output is correct
37 Correct 458 ms 3508 KB Output is correct
38 Correct 457 ms 3436 KB Output is correct
39 Correct 566 ms 3308 KB Output is correct
40 Correct 619 ms 3564 KB Output is correct
41 Correct 622 ms 3308 KB Output is correct
42 Correct 547 ms 3564 KB Output is correct
43 Correct 559 ms 3820 KB Output is correct
44 Correct 569 ms 3692 KB Output is correct
45 Correct 576 ms 3692 KB Output is correct
46 Correct 616 ms 3308 KB Output is correct
47 Correct 570 ms 3460 KB Output is correct
48 Correct 574 ms 3564 KB Output is correct
49 Correct 575 ms 3436 KB Output is correct
50 Correct 569 ms 3564 KB Output is correct
51 Correct 1 ms 1260 KB Output is correct
52 Correct 614 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 30 ms 3308 KB Output is correct
6 Correct 21 ms 3308 KB Output is correct
7 Correct 17 ms 3308 KB Output is correct
8 Correct 30 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 69 ms 3308 KB Output is correct
11 Correct 68 ms 3436 KB Output is correct
12 Correct 68 ms 3308 KB Output is correct
13 Correct 2 ms 1260 KB Output is correct
14 Correct 68 ms 3308 KB Output is correct
15 Correct 66 ms 3328 KB Output is correct
16 Correct 70 ms 3308 KB Output is correct
17 Correct 46 ms 3308 KB Output is correct
18 Correct 57 ms 3308 KB Output is correct
19 Correct 62 ms 3308 KB Output is correct
20 Correct 70 ms 3308 KB Output is correct
21 Correct 148 ms 3308 KB Output is correct
22 Correct 172 ms 3436 KB Output is correct
23 Correct 118 ms 3332 KB Output is correct
24 Correct 216 ms 3308 KB Output is correct
25 Correct 221 ms 3308 KB Output is correct
26 Correct 231 ms 3308 KB Output is correct
27 Correct 229 ms 3308 KB Output is correct
28 Correct 232 ms 3308 KB Output is correct
29 Correct 232 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 230 ms 3308 KB Output is correct
32 Correct 232 ms 3436 KB Output is correct
33 Correct 229 ms 3308 KB Output is correct
34 Correct 229 ms 3308 KB Output is correct
35 Correct 228 ms 3308 KB Output is correct
36 Correct 230 ms 3308 KB Output is correct
37 Correct 458 ms 3508 KB Output is correct
38 Correct 457 ms 3436 KB Output is correct
39 Correct 566 ms 3308 KB Output is correct
40 Correct 619 ms 3564 KB Output is correct
41 Correct 622 ms 3308 KB Output is correct
42 Correct 547 ms 3564 KB Output is correct
43 Correct 559 ms 3820 KB Output is correct
44 Correct 569 ms 3692 KB Output is correct
45 Correct 576 ms 3692 KB Output is correct
46 Correct 616 ms 3308 KB Output is correct
47 Correct 570 ms 3460 KB Output is correct
48 Correct 574 ms 3564 KB Output is correct
49 Correct 575 ms 3436 KB Output is correct
50 Correct 569 ms 3564 KB Output is correct
51 Correct 1 ms 1260 KB Output is correct
52 Correct 614 ms 3820 KB Output is correct
53 Correct 678 ms 3636 KB Output is correct
54 Correct 800 ms 3692 KB Output is correct
55 Correct 801 ms 4080 KB Output is correct
56 Correct 702 ms 3692 KB Output is correct
57 Correct 775 ms 4080 KB Output is correct
58 Correct 792 ms 3820 KB Output is correct
59 Correct 804 ms 3824 KB Output is correct
60 Correct 1 ms 1260 KB Output is correct
61 Correct 800 ms 3896 KB Output is correct
62 Correct 733 ms 3904 KB Output is correct
63 Correct 734 ms 4228 KB Output is correct
64 Correct 730 ms 3952 KB Output is correct
65 Correct 731 ms 3420 KB Output is correct
66 Correct 716 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 30 ms 3308 KB Output is correct
6 Correct 21 ms 3308 KB Output is correct
7 Correct 17 ms 3308 KB Output is correct
8 Correct 30 ms 3308 KB Output is correct
9 Correct 1 ms 1260 KB Output is correct
10 Correct 69 ms 3308 KB Output is correct
11 Correct 68 ms 3436 KB Output is correct
12 Correct 68 ms 3308 KB Output is correct
13 Correct 2 ms 1260 KB Output is correct
14 Correct 68 ms 3308 KB Output is correct
15 Correct 66 ms 3328 KB Output is correct
16 Correct 70 ms 3308 KB Output is correct
17 Correct 46 ms 3308 KB Output is correct
18 Correct 57 ms 3308 KB Output is correct
19 Correct 62 ms 3308 KB Output is correct
20 Correct 70 ms 3308 KB Output is correct
21 Correct 148 ms 3308 KB Output is correct
22 Correct 172 ms 3436 KB Output is correct
23 Correct 118 ms 3332 KB Output is correct
24 Correct 216 ms 3308 KB Output is correct
25 Correct 221 ms 3308 KB Output is correct
26 Correct 231 ms 3308 KB Output is correct
27 Correct 229 ms 3308 KB Output is correct
28 Correct 232 ms 3308 KB Output is correct
29 Correct 232 ms 3308 KB Output is correct
30 Correct 1 ms 1260 KB Output is correct
31 Correct 230 ms 3308 KB Output is correct
32 Correct 232 ms 3436 KB Output is correct
33 Correct 229 ms 3308 KB Output is correct
34 Correct 229 ms 3308 KB Output is correct
35 Correct 228 ms 3308 KB Output is correct
36 Correct 230 ms 3308 KB Output is correct
37 Correct 458 ms 3508 KB Output is correct
38 Correct 457 ms 3436 KB Output is correct
39 Correct 566 ms 3308 KB Output is correct
40 Correct 619 ms 3564 KB Output is correct
41 Correct 622 ms 3308 KB Output is correct
42 Correct 547 ms 3564 KB Output is correct
43 Correct 559 ms 3820 KB Output is correct
44 Correct 569 ms 3692 KB Output is correct
45 Correct 576 ms 3692 KB Output is correct
46 Correct 616 ms 3308 KB Output is correct
47 Correct 570 ms 3460 KB Output is correct
48 Correct 574 ms 3564 KB Output is correct
49 Correct 575 ms 3436 KB Output is correct
50 Correct 569 ms 3564 KB Output is correct
51 Correct 1 ms 1260 KB Output is correct
52 Correct 614 ms 3820 KB Output is correct
53 Correct 678 ms 3636 KB Output is correct
54 Correct 800 ms 3692 KB Output is correct
55 Correct 801 ms 4080 KB Output is correct
56 Correct 702 ms 3692 KB Output is correct
57 Correct 775 ms 4080 KB Output is correct
58 Correct 792 ms 3820 KB Output is correct
59 Correct 804 ms 3824 KB Output is correct
60 Correct 1 ms 1260 KB Output is correct
61 Correct 800 ms 3896 KB Output is correct
62 Correct 733 ms 3904 KB Output is correct
63 Correct 734 ms 4228 KB Output is correct
64 Correct 730 ms 3952 KB Output is correct
65 Correct 731 ms 3420 KB Output is correct
66 Correct 716 ms 3332 KB Output is correct
67 Correct 893 ms 3824 KB Output is correct
68 Correct 421 ms 2284 KB Output is correct
69 Execution timed out 1090 ms 3308 KB Time limit exceeded
70 Halted 0 ms 0 KB -