Submission #343368

# Submission time Handle Problem Language Result Execution time Memory
343368 2021-01-03T19:02:26 Z spike1236 Bootfall (IZhO17_bootfall) C++14
100 / 100
338 ms 4460 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) {
    for(int i = sum; i >= 0; --i)
        dp[i + x] += dp[i];
    sum += x;
}

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

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 0 ms 364 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 5 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1260 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1260 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 0 ms 364 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 5 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1260 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1260 KB Output is correct
10 Correct 10 ms 1260 KB Output is correct
11 Correct 10 ms 1260 KB Output is correct
12 Correct 10 ms 1260 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 10 ms 1260 KB Output is correct
15 Correct 10 ms 1260 KB Output is correct
16 Correct 11 ms 1268 KB Output is correct
17 Correct 9 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 11 ms 1260 KB Output is correct
20 Correct 10 ms 1260 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 0 ms 364 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 5 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1260 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1260 KB Output is correct
10 Correct 10 ms 1260 KB Output is correct
11 Correct 10 ms 1260 KB Output is correct
12 Correct 10 ms 1260 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 10 ms 1260 KB Output is correct
15 Correct 10 ms 1260 KB Output is correct
16 Correct 11 ms 1268 KB Output is correct
17 Correct 9 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 11 ms 1260 KB Output is correct
20 Correct 10 ms 1260 KB Output is correct
21 Correct 21 ms 1388 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 19 ms 1516 KB Output is correct
24 Correct 29 ms 1400 KB Output is correct
25 Correct 30 ms 1388 KB Output is correct
26 Correct 33 ms 1388 KB Output is correct
27 Correct 32 ms 1388 KB Output is correct
28 Correct 39 ms 1388 KB Output is correct
29 Correct 33 ms 1388 KB Output is correct
30 Correct 31 ms 1388 KB Output is correct
31 Correct 33 ms 1388 KB Output is correct
32 Correct 31 ms 1388 KB Output is correct
33 Correct 32 ms 1388 KB Output is correct
34 Correct 33 ms 1388 KB Output is correct
35 Correct 32 ms 1388 KB Output is correct
36 Correct 31 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 0 ms 364 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 5 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1260 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1260 KB Output is correct
10 Correct 10 ms 1260 KB Output is correct
11 Correct 10 ms 1260 KB Output is correct
12 Correct 10 ms 1260 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 10 ms 1260 KB Output is correct
15 Correct 10 ms 1260 KB Output is correct
16 Correct 11 ms 1268 KB Output is correct
17 Correct 9 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 11 ms 1260 KB Output is correct
20 Correct 10 ms 1260 KB Output is correct
21 Correct 21 ms 1388 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 19 ms 1516 KB Output is correct
24 Correct 29 ms 1400 KB Output is correct
25 Correct 30 ms 1388 KB Output is correct
26 Correct 33 ms 1388 KB Output is correct
27 Correct 32 ms 1388 KB Output is correct
28 Correct 39 ms 1388 KB Output is correct
29 Correct 33 ms 1388 KB Output is correct
30 Correct 31 ms 1388 KB Output is correct
31 Correct 33 ms 1388 KB Output is correct
32 Correct 31 ms 1388 KB Output is correct
33 Correct 32 ms 1388 KB Output is correct
34 Correct 33 ms 1388 KB Output is correct
35 Correct 32 ms 1388 KB Output is correct
36 Correct 31 ms 1388 KB Output is correct
37 Correct 66 ms 1772 KB Output is correct
38 Correct 67 ms 1644 KB Output is correct
39 Correct 95 ms 1772 KB Output is correct
40 Correct 94 ms 1772 KB Output is correct
41 Correct 107 ms 1900 KB Output is correct
42 Correct 86 ms 1772 KB Output is correct
43 Correct 92 ms 2284 KB Output is correct
44 Correct 95 ms 2156 KB Output is correct
45 Correct 97 ms 2156 KB Output is correct
46 Correct 91 ms 1660 KB Output is correct
47 Correct 88 ms 1772 KB Output is correct
48 Correct 98 ms 2156 KB Output is correct
49 Correct 100 ms 1900 KB Output is correct
50 Correct 91 ms 1772 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 108 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 0 ms 364 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 5 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1260 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1260 KB Output is correct
10 Correct 10 ms 1260 KB Output is correct
11 Correct 10 ms 1260 KB Output is correct
12 Correct 10 ms 1260 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 10 ms 1260 KB Output is correct
15 Correct 10 ms 1260 KB Output is correct
16 Correct 11 ms 1268 KB Output is correct
17 Correct 9 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 11 ms 1260 KB Output is correct
20 Correct 10 ms 1260 KB Output is correct
21 Correct 21 ms 1388 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 19 ms 1516 KB Output is correct
24 Correct 29 ms 1400 KB Output is correct
25 Correct 30 ms 1388 KB Output is correct
26 Correct 33 ms 1388 KB Output is correct
27 Correct 32 ms 1388 KB Output is correct
28 Correct 39 ms 1388 KB Output is correct
29 Correct 33 ms 1388 KB Output is correct
30 Correct 31 ms 1388 KB Output is correct
31 Correct 33 ms 1388 KB Output is correct
32 Correct 31 ms 1388 KB Output is correct
33 Correct 32 ms 1388 KB Output is correct
34 Correct 33 ms 1388 KB Output is correct
35 Correct 32 ms 1388 KB Output is correct
36 Correct 31 ms 1388 KB Output is correct
37 Correct 66 ms 1772 KB Output is correct
38 Correct 67 ms 1644 KB Output is correct
39 Correct 95 ms 1772 KB Output is correct
40 Correct 94 ms 1772 KB Output is correct
41 Correct 107 ms 1900 KB Output is correct
42 Correct 86 ms 1772 KB Output is correct
43 Correct 92 ms 2284 KB Output is correct
44 Correct 95 ms 2156 KB Output is correct
45 Correct 97 ms 2156 KB Output is correct
46 Correct 91 ms 1660 KB Output is correct
47 Correct 88 ms 1772 KB Output is correct
48 Correct 98 ms 2156 KB Output is correct
49 Correct 100 ms 1900 KB Output is correct
50 Correct 91 ms 1772 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 108 ms 2284 KB Output is correct
53 Correct 112 ms 2028 KB Output is correct
54 Correct 134 ms 2284 KB Output is correct
55 Correct 164 ms 2800 KB Output is correct
56 Correct 118 ms 2200 KB Output is correct
57 Correct 166 ms 2928 KB Output is correct
58 Correct 137 ms 2284 KB Output is correct
59 Correct 144 ms 2416 KB Output is correct
60 Correct 7 ms 876 KB Output is correct
61 Correct 150 ms 2544 KB Output is correct
62 Correct 140 ms 2672 KB Output is correct
63 Correct 146 ms 2800 KB Output is correct
64 Correct 141 ms 2800 KB Output is correct
65 Correct 118 ms 1772 KB Output is correct
66 Correct 114 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 0 ms 364 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 5 ms 1388 KB Output is correct
6 Correct 4 ms 1260 KB Output is correct
7 Correct 4 ms 1260 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1260 KB Output is correct
10 Correct 10 ms 1260 KB Output is correct
11 Correct 10 ms 1260 KB Output is correct
12 Correct 10 ms 1260 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 10 ms 1260 KB Output is correct
15 Correct 10 ms 1260 KB Output is correct
16 Correct 11 ms 1268 KB Output is correct
17 Correct 9 ms 1260 KB Output is correct
18 Correct 9 ms 1260 KB Output is correct
19 Correct 11 ms 1260 KB Output is correct
20 Correct 10 ms 1260 KB Output is correct
21 Correct 21 ms 1388 KB Output is correct
22 Correct 25 ms 1388 KB Output is correct
23 Correct 19 ms 1516 KB Output is correct
24 Correct 29 ms 1400 KB Output is correct
25 Correct 30 ms 1388 KB Output is correct
26 Correct 33 ms 1388 KB Output is correct
27 Correct 32 ms 1388 KB Output is correct
28 Correct 39 ms 1388 KB Output is correct
29 Correct 33 ms 1388 KB Output is correct
30 Correct 31 ms 1388 KB Output is correct
31 Correct 33 ms 1388 KB Output is correct
32 Correct 31 ms 1388 KB Output is correct
33 Correct 32 ms 1388 KB Output is correct
34 Correct 33 ms 1388 KB Output is correct
35 Correct 32 ms 1388 KB Output is correct
36 Correct 31 ms 1388 KB Output is correct
37 Correct 66 ms 1772 KB Output is correct
38 Correct 67 ms 1644 KB Output is correct
39 Correct 95 ms 1772 KB Output is correct
40 Correct 94 ms 1772 KB Output is correct
41 Correct 107 ms 1900 KB Output is correct
42 Correct 86 ms 1772 KB Output is correct
43 Correct 92 ms 2284 KB Output is correct
44 Correct 95 ms 2156 KB Output is correct
45 Correct 97 ms 2156 KB Output is correct
46 Correct 91 ms 1660 KB Output is correct
47 Correct 88 ms 1772 KB Output is correct
48 Correct 98 ms 2156 KB Output is correct
49 Correct 100 ms 1900 KB Output is correct
50 Correct 91 ms 1772 KB Output is correct
51 Correct 3 ms 620 KB Output is correct
52 Correct 108 ms 2284 KB Output is correct
53 Correct 112 ms 2028 KB Output is correct
54 Correct 134 ms 2284 KB Output is correct
55 Correct 164 ms 2800 KB Output is correct
56 Correct 118 ms 2200 KB Output is correct
57 Correct 166 ms 2928 KB Output is correct
58 Correct 137 ms 2284 KB Output is correct
59 Correct 144 ms 2416 KB Output is correct
60 Correct 7 ms 876 KB Output is correct
61 Correct 150 ms 2544 KB Output is correct
62 Correct 140 ms 2672 KB Output is correct
63 Correct 146 ms 2800 KB Output is correct
64 Correct 141 ms 2800 KB Output is correct
65 Correct 118 ms 1772 KB Output is correct
66 Correct 114 ms 1772 KB Output is correct
67 Correct 171 ms 2544 KB Output is correct
68 Correct 18 ms 1260 KB Output is correct
69 Correct 308 ms 4188 KB Output is correct
70 Correct 244 ms 3056 KB Output is correct
71 Correct 240 ms 3184 KB Output is correct
72 Correct 235 ms 2284 KB Output is correct
73 Correct 235 ms 2284 KB Output is correct
74 Correct 311 ms 4332 KB Output is correct
75 Correct 278 ms 3692 KB Output is correct
76 Correct 330 ms 4460 KB Output is correct
77 Correct 338 ms 4460 KB Output is correct