Submission #343364

# Submission time Handle Problem Language Result Execution time Memory
343364 2021-01-03T18:54:50 Z spike1236 Bootfall (IZhO17_bootfall) C++14
100 / 100
382 ms 4588 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MX = 250010;
int n;
int a[510];
int used[MX];
ll dp[MX];
int sum;

void add(int x) {
    sum += x;
    for(int i = sum; i >= x; --i)
        dp[i] += dp[i - x];
}

void del(int x) {
    for(int i = x; i <= sum; ++i)
        dp[i] -= dp[i - x];
    sum -= x;
}

void solve() {
    cin >> n;
    dp[0] = 1;
    for(int i = 1; i <= n; ++i) cin >> a[i], add(a[i]);
    if(sum & 1 || !dp[sum / 2]) {
        cout << 0;
        return;
    }
    veci ans;
    for(int i = 1; i <= n; ++i) {
        del(a[i]);
        for(int j = 1; j < MX; ++j)
            if((sum + j) & 1 || !dp[(sum + j) / 2])
                used[j] = 1;
        add(a[i]);
    }
    for(int i = 1; i < MX; ++i)
        if(!used[i])
            ans.pb(i);
    cout << sz(ans) << '\n';
    for(auto it : ans) cout << it << ' ';
}


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 4 ms 1260 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 6 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1388 KB Output is correct
8 Correct 6 ms 1388 KB Output is correct
9 Correct 5 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 4 ms 1260 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 6 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1388 KB Output is correct
8 Correct 6 ms 1388 KB Output is correct
9 Correct 5 ms 1388 KB Output is correct
10 Correct 11 ms 1388 KB Output is correct
11 Correct 11 ms 1260 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 10 ms 1260 KB Output is correct
14 Correct 11 ms 1388 KB Output is correct
15 Correct 11 ms 1260 KB Output is correct
16 Correct 11 ms 1260 KB Output is correct
17 Correct 7 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 10 ms 1260 KB Output is correct
20 Correct 11 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 4 ms 1260 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 6 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1388 KB Output is correct
8 Correct 6 ms 1388 KB Output is correct
9 Correct 5 ms 1388 KB Output is correct
10 Correct 11 ms 1388 KB Output is correct
11 Correct 11 ms 1260 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 10 ms 1260 KB Output is correct
14 Correct 11 ms 1388 KB Output is correct
15 Correct 11 ms 1260 KB Output is correct
16 Correct 11 ms 1260 KB Output is correct
17 Correct 7 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 10 ms 1260 KB Output is correct
20 Correct 11 ms 1388 KB Output is correct
21 Correct 22 ms 1516 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 18 ms 1388 KB Output is correct
24 Correct 35 ms 1388 KB Output is correct
25 Correct 35 ms 1516 KB Output is correct
26 Correct 35 ms 1388 KB Output is correct
27 Correct 34 ms 1388 KB Output is correct
28 Correct 36 ms 1516 KB Output is correct
29 Correct 35 ms 1388 KB Output is correct
30 Correct 34 ms 1388 KB Output is correct
31 Correct 34 ms 1388 KB Output is correct
32 Correct 34 ms 1388 KB Output is correct
33 Correct 34 ms 1388 KB Output is correct
34 Correct 34 ms 1388 KB Output is correct
35 Correct 34 ms 1388 KB Output is correct
36 Correct 34 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 4 ms 1260 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 6 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1388 KB Output is correct
8 Correct 6 ms 1388 KB Output is correct
9 Correct 5 ms 1388 KB Output is correct
10 Correct 11 ms 1388 KB Output is correct
11 Correct 11 ms 1260 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 10 ms 1260 KB Output is correct
14 Correct 11 ms 1388 KB Output is correct
15 Correct 11 ms 1260 KB Output is correct
16 Correct 11 ms 1260 KB Output is correct
17 Correct 7 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 10 ms 1260 KB Output is correct
20 Correct 11 ms 1388 KB Output is correct
21 Correct 22 ms 1516 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 18 ms 1388 KB Output is correct
24 Correct 35 ms 1388 KB Output is correct
25 Correct 35 ms 1516 KB Output is correct
26 Correct 35 ms 1388 KB Output is correct
27 Correct 34 ms 1388 KB Output is correct
28 Correct 36 ms 1516 KB Output is correct
29 Correct 35 ms 1388 KB Output is correct
30 Correct 34 ms 1388 KB Output is correct
31 Correct 34 ms 1388 KB Output is correct
32 Correct 34 ms 1388 KB Output is correct
33 Correct 34 ms 1388 KB Output is correct
34 Correct 34 ms 1388 KB Output is correct
35 Correct 34 ms 1388 KB Output is correct
36 Correct 34 ms 1388 KB Output is correct
37 Correct 74 ms 1644 KB Output is correct
38 Correct 82 ms 1644 KB Output is correct
39 Correct 114 ms 1772 KB Output is correct
40 Correct 101 ms 1772 KB Output is correct
41 Correct 113 ms 1900 KB Output is correct
42 Correct 96 ms 1772 KB Output is correct
43 Correct 124 ms 2304 KB Output is correct
44 Correct 106 ms 2156 KB Output is correct
45 Correct 105 ms 2208 KB Output is correct
46 Correct 99 ms 1644 KB Output is correct
47 Correct 94 ms 1772 KB Output is correct
48 Correct 110 ms 2156 KB Output is correct
49 Correct 106 ms 1900 KB Output is correct
50 Correct 106 ms 1772 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 123 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 4 ms 1260 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 6 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1388 KB Output is correct
8 Correct 6 ms 1388 KB Output is correct
9 Correct 5 ms 1388 KB Output is correct
10 Correct 11 ms 1388 KB Output is correct
11 Correct 11 ms 1260 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 10 ms 1260 KB Output is correct
14 Correct 11 ms 1388 KB Output is correct
15 Correct 11 ms 1260 KB Output is correct
16 Correct 11 ms 1260 KB Output is correct
17 Correct 7 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 10 ms 1260 KB Output is correct
20 Correct 11 ms 1388 KB Output is correct
21 Correct 22 ms 1516 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 18 ms 1388 KB Output is correct
24 Correct 35 ms 1388 KB Output is correct
25 Correct 35 ms 1516 KB Output is correct
26 Correct 35 ms 1388 KB Output is correct
27 Correct 34 ms 1388 KB Output is correct
28 Correct 36 ms 1516 KB Output is correct
29 Correct 35 ms 1388 KB Output is correct
30 Correct 34 ms 1388 KB Output is correct
31 Correct 34 ms 1388 KB Output is correct
32 Correct 34 ms 1388 KB Output is correct
33 Correct 34 ms 1388 KB Output is correct
34 Correct 34 ms 1388 KB Output is correct
35 Correct 34 ms 1388 KB Output is correct
36 Correct 34 ms 1388 KB Output is correct
37 Correct 74 ms 1644 KB Output is correct
38 Correct 82 ms 1644 KB Output is correct
39 Correct 114 ms 1772 KB Output is correct
40 Correct 101 ms 1772 KB Output is correct
41 Correct 113 ms 1900 KB Output is correct
42 Correct 96 ms 1772 KB Output is correct
43 Correct 124 ms 2304 KB Output is correct
44 Correct 106 ms 2156 KB Output is correct
45 Correct 105 ms 2208 KB Output is correct
46 Correct 99 ms 1644 KB Output is correct
47 Correct 94 ms 1772 KB Output is correct
48 Correct 110 ms 2156 KB Output is correct
49 Correct 106 ms 1900 KB Output is correct
50 Correct 106 ms 1772 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 123 ms 2284 KB Output is correct
53 Correct 119 ms 2028 KB Output is correct
54 Correct 146 ms 2284 KB Output is correct
55 Correct 187 ms 2928 KB Output is correct
56 Correct 135 ms 2156 KB Output is correct
57 Correct 212 ms 3056 KB Output is correct
58 Correct 150 ms 2284 KB Output is correct
59 Correct 162 ms 2416 KB Output is correct
60 Correct 7 ms 876 KB Output is correct
61 Correct 174 ms 2672 KB Output is correct
62 Correct 169 ms 2672 KB Output is correct
63 Correct 163 ms 2800 KB Output is correct
64 Correct 165 ms 2800 KB Output is correct
65 Correct 126 ms 1772 KB Output is correct
66 Correct 129 ms 1772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1260 KB Output is correct
2 Correct 4 ms 1260 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 6 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1388 KB Output is correct
8 Correct 6 ms 1388 KB Output is correct
9 Correct 5 ms 1388 KB Output is correct
10 Correct 11 ms 1388 KB Output is correct
11 Correct 11 ms 1260 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 10 ms 1260 KB Output is correct
14 Correct 11 ms 1388 KB Output is correct
15 Correct 11 ms 1260 KB Output is correct
16 Correct 11 ms 1260 KB Output is correct
17 Correct 7 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 10 ms 1260 KB Output is correct
20 Correct 11 ms 1388 KB Output is correct
21 Correct 22 ms 1516 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 18 ms 1388 KB Output is correct
24 Correct 35 ms 1388 KB Output is correct
25 Correct 35 ms 1516 KB Output is correct
26 Correct 35 ms 1388 KB Output is correct
27 Correct 34 ms 1388 KB Output is correct
28 Correct 36 ms 1516 KB Output is correct
29 Correct 35 ms 1388 KB Output is correct
30 Correct 34 ms 1388 KB Output is correct
31 Correct 34 ms 1388 KB Output is correct
32 Correct 34 ms 1388 KB Output is correct
33 Correct 34 ms 1388 KB Output is correct
34 Correct 34 ms 1388 KB Output is correct
35 Correct 34 ms 1388 KB Output is correct
36 Correct 34 ms 1388 KB Output is correct
37 Correct 74 ms 1644 KB Output is correct
38 Correct 82 ms 1644 KB Output is correct
39 Correct 114 ms 1772 KB Output is correct
40 Correct 101 ms 1772 KB Output is correct
41 Correct 113 ms 1900 KB Output is correct
42 Correct 96 ms 1772 KB Output is correct
43 Correct 124 ms 2304 KB Output is correct
44 Correct 106 ms 2156 KB Output is correct
45 Correct 105 ms 2208 KB Output is correct
46 Correct 99 ms 1644 KB Output is correct
47 Correct 94 ms 1772 KB Output is correct
48 Correct 110 ms 2156 KB Output is correct
49 Correct 106 ms 1900 KB Output is correct
50 Correct 106 ms 1772 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 123 ms 2284 KB Output is correct
53 Correct 119 ms 2028 KB Output is correct
54 Correct 146 ms 2284 KB Output is correct
55 Correct 187 ms 2928 KB Output is correct
56 Correct 135 ms 2156 KB Output is correct
57 Correct 212 ms 3056 KB Output is correct
58 Correct 150 ms 2284 KB Output is correct
59 Correct 162 ms 2416 KB Output is correct
60 Correct 7 ms 876 KB Output is correct
61 Correct 174 ms 2672 KB Output is correct
62 Correct 169 ms 2672 KB Output is correct
63 Correct 163 ms 2800 KB Output is correct
64 Correct 165 ms 2800 KB Output is correct
65 Correct 126 ms 1772 KB Output is correct
66 Correct 129 ms 1772 KB Output is correct
67 Correct 185 ms 2416 KB Output is correct
68 Correct 19 ms 1260 KB Output is correct
69 Correct 357 ms 4204 KB Output is correct
70 Correct 296 ms 3056 KB Output is correct
71 Correct 270 ms 3184 KB Output is correct
72 Correct 264 ms 2284 KB Output is correct
73 Correct 271 ms 2284 KB Output is correct
74 Correct 356 ms 4588 KB Output is correct
75 Correct 314 ms 3912 KB Output is correct
76 Correct 374 ms 4460 KB Output is correct
77 Correct 382 ms 4588 KB Output is correct