Submission #342911

# Submission time Handle Problem Language Result Execution time Memory
342911 2021-01-03T08:03:59 Z vonatlus Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 1648 KB
/// vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;
const int B = 2e5+6e4;

bitset<B> dp;
   
int cnt[B];

void ma1n() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for (int& x : a) {
        cin >> x, s += x;
    }
    if (s&1) cout << 0, exit(0);
    for (int i = -1; i < n; ++i) {
        dp.reset();
        dp.set(0, 1);
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            dp |= dp<<a[j];
        }
        if (i == -1) {
            if (!dp[s/2]) {
                cout << 0, exit(0);
            }
            continue;    
        }
        for (int b = 0; b <= s/2; ++b) {
            if (dp[b]) {
                int balance = s-a[i]-b-b;
                if (balance > 0) {
                    cnt[balance]++;
                }
            }
        }
    }
    vector<int> ans;
    for (int i = 0; i <= s; ++i) {
        if (cnt[i] == n) {
            ans.pb(i);
        }
    }
    cout << sz(ans) << "\n";
    for (int x : ans) cout << x << " ";
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 8 ms 364 KB Output is correct
11 Correct 8 ms 364 KB Output is correct
12 Correct 8 ms 364 KB Output is correct
13 Correct 6 ms 364 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 7 ms 364 KB Output is correct
16 Correct 8 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 8 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 8 ms 364 KB Output is correct
11 Correct 8 ms 364 KB Output is correct
12 Correct 8 ms 364 KB Output is correct
13 Correct 6 ms 364 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 7 ms 364 KB Output is correct
16 Correct 8 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 8 ms 364 KB Output is correct
21 Correct 37 ms 492 KB Output is correct
22 Correct 54 ms 492 KB Output is correct
23 Correct 22 ms 492 KB Output is correct
24 Correct 73 ms 492 KB Output is correct
25 Correct 72 ms 492 KB Output is correct
26 Correct 81 ms 492 KB Output is correct
27 Correct 81 ms 512 KB Output is correct
28 Correct 82 ms 492 KB Output is correct
29 Correct 81 ms 492 KB Output is correct
30 Correct 92 ms 620 KB Output is correct
31 Correct 81 ms 492 KB Output is correct
32 Correct 80 ms 620 KB Output is correct
33 Correct 81 ms 620 KB Output is correct
34 Correct 82 ms 492 KB Output is correct
35 Correct 81 ms 620 KB Output is correct
36 Correct 81 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 8 ms 364 KB Output is correct
11 Correct 8 ms 364 KB Output is correct
12 Correct 8 ms 364 KB Output is correct
13 Correct 6 ms 364 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 7 ms 364 KB Output is correct
16 Correct 8 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 8 ms 364 KB Output is correct
21 Correct 37 ms 492 KB Output is correct
22 Correct 54 ms 492 KB Output is correct
23 Correct 22 ms 492 KB Output is correct
24 Correct 73 ms 492 KB Output is correct
25 Correct 72 ms 492 KB Output is correct
26 Correct 81 ms 492 KB Output is correct
27 Correct 81 ms 512 KB Output is correct
28 Correct 82 ms 492 KB Output is correct
29 Correct 81 ms 492 KB Output is correct
30 Correct 92 ms 620 KB Output is correct
31 Correct 81 ms 492 KB Output is correct
32 Correct 80 ms 620 KB Output is correct
33 Correct 81 ms 620 KB Output is correct
34 Correct 82 ms 492 KB Output is correct
35 Correct 81 ms 620 KB Output is correct
36 Correct 81 ms 504 KB Output is correct
37 Correct 320 ms 876 KB Output is correct
38 Correct 321 ms 692 KB Output is correct
39 Correct 433 ms 748 KB Output is correct
40 Correct 557 ms 748 KB Output is correct
41 Correct 507 ms 876 KB Output is correct
42 Correct 481 ms 748 KB Output is correct
43 Correct 430 ms 1132 KB Output is correct
44 Correct 463 ms 1004 KB Output is correct
45 Correct 456 ms 1132 KB Output is correct
46 Correct 585 ms 612 KB Output is correct
47 Correct 478 ms 748 KB Output is correct
48 Correct 452 ms 1004 KB Output is correct
49 Correct 442 ms 748 KB Output is correct
50 Correct 472 ms 748 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 532 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 8 ms 364 KB Output is correct
11 Correct 8 ms 364 KB Output is correct
12 Correct 8 ms 364 KB Output is correct
13 Correct 6 ms 364 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 7 ms 364 KB Output is correct
16 Correct 8 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 8 ms 364 KB Output is correct
21 Correct 37 ms 492 KB Output is correct
22 Correct 54 ms 492 KB Output is correct
23 Correct 22 ms 492 KB Output is correct
24 Correct 73 ms 492 KB Output is correct
25 Correct 72 ms 492 KB Output is correct
26 Correct 81 ms 492 KB Output is correct
27 Correct 81 ms 512 KB Output is correct
28 Correct 82 ms 492 KB Output is correct
29 Correct 81 ms 492 KB Output is correct
30 Correct 92 ms 620 KB Output is correct
31 Correct 81 ms 492 KB Output is correct
32 Correct 80 ms 620 KB Output is correct
33 Correct 81 ms 620 KB Output is correct
34 Correct 82 ms 492 KB Output is correct
35 Correct 81 ms 620 KB Output is correct
36 Correct 81 ms 504 KB Output is correct
37 Correct 320 ms 876 KB Output is correct
38 Correct 321 ms 692 KB Output is correct
39 Correct 433 ms 748 KB Output is correct
40 Correct 557 ms 748 KB Output is correct
41 Correct 507 ms 876 KB Output is correct
42 Correct 481 ms 748 KB Output is correct
43 Correct 430 ms 1132 KB Output is correct
44 Correct 463 ms 1004 KB Output is correct
45 Correct 456 ms 1132 KB Output is correct
46 Correct 585 ms 612 KB Output is correct
47 Correct 478 ms 748 KB Output is correct
48 Correct 452 ms 1004 KB Output is correct
49 Correct 442 ms 748 KB Output is correct
50 Correct 472 ms 748 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 532 ms 1132 KB Output is correct
53 Correct 688 ms 920 KB Output is correct
54 Correct 954 ms 1088 KB Output is correct
55 Correct 918 ms 1648 KB Output is correct
56 Correct 704 ms 1132 KB Output is correct
57 Correct 918 ms 1520 KB Output is correct
58 Correct 927 ms 1112 KB Output is correct
59 Correct 914 ms 1264 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 902 ms 1264 KB Output is correct
62 Correct 764 ms 1520 KB Output is correct
63 Correct 793 ms 1392 KB Output is correct
64 Correct 736 ms 1552 KB Output is correct
65 Correct 730 ms 748 KB Output is correct
66 Correct 694 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 8 ms 364 KB Output is correct
11 Correct 8 ms 364 KB Output is correct
12 Correct 8 ms 364 KB Output is correct
13 Correct 6 ms 364 KB Output is correct
14 Correct 9 ms 492 KB Output is correct
15 Correct 7 ms 364 KB Output is correct
16 Correct 8 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 5 ms 364 KB Output is correct
19 Correct 6 ms 364 KB Output is correct
20 Correct 8 ms 364 KB Output is correct
21 Correct 37 ms 492 KB Output is correct
22 Correct 54 ms 492 KB Output is correct
23 Correct 22 ms 492 KB Output is correct
24 Correct 73 ms 492 KB Output is correct
25 Correct 72 ms 492 KB Output is correct
26 Correct 81 ms 492 KB Output is correct
27 Correct 81 ms 512 KB Output is correct
28 Correct 82 ms 492 KB Output is correct
29 Correct 81 ms 492 KB Output is correct
30 Correct 92 ms 620 KB Output is correct
31 Correct 81 ms 492 KB Output is correct
32 Correct 80 ms 620 KB Output is correct
33 Correct 81 ms 620 KB Output is correct
34 Correct 82 ms 492 KB Output is correct
35 Correct 81 ms 620 KB Output is correct
36 Correct 81 ms 504 KB Output is correct
37 Correct 320 ms 876 KB Output is correct
38 Correct 321 ms 692 KB Output is correct
39 Correct 433 ms 748 KB Output is correct
40 Correct 557 ms 748 KB Output is correct
41 Correct 507 ms 876 KB Output is correct
42 Correct 481 ms 748 KB Output is correct
43 Correct 430 ms 1132 KB Output is correct
44 Correct 463 ms 1004 KB Output is correct
45 Correct 456 ms 1132 KB Output is correct
46 Correct 585 ms 612 KB Output is correct
47 Correct 478 ms 748 KB Output is correct
48 Correct 452 ms 1004 KB Output is correct
49 Correct 442 ms 748 KB Output is correct
50 Correct 472 ms 748 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 532 ms 1132 KB Output is correct
53 Correct 688 ms 920 KB Output is correct
54 Correct 954 ms 1088 KB Output is correct
55 Correct 918 ms 1648 KB Output is correct
56 Correct 704 ms 1132 KB Output is correct
57 Correct 918 ms 1520 KB Output is correct
58 Correct 927 ms 1112 KB Output is correct
59 Correct 914 ms 1264 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 902 ms 1264 KB Output is correct
62 Correct 764 ms 1520 KB Output is correct
63 Correct 793 ms 1392 KB Output is correct
64 Correct 736 ms 1552 KB Output is correct
65 Correct 730 ms 748 KB Output is correct
66 Correct 694 ms 696 KB Output is correct
67 Execution timed out 1090 ms 748 KB Time limit exceeded
68 Halted 0 ms 0 KB -