Submission #982146

# Submission time Handle Problem Language Result Execution time Memory
982146 2024-05-14T01:03:28 Z LOLOLO Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 4128 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
#define           f     first
#define           s     second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 500 + 30;
const int M = 500 * 500 + 10;
int f[M + 10], f2[M], cnt[M], mod = 1e8 + 3;
int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    f[0] = 1;

    ll sum = 0;
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        for (int j = M; j >= a[i]; j--) {
            f[j] = (f[j] + f[j - a[i]]) % mod;
        }
    }

    if (sum % 2 == 0) {
        if (f[sum / 2] == 0) {
            cout << 0 << '\n';
            return 0;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= M; j++) {
            if (j >= a[i]) {
                f2[j] = (f[j] - f2[j - a[i]] + mod);
                while (f2[j] >= mod)
                    f2[j] -= mod;
            } else {
                f2[j] = f[j]; 
            }
        }

        for (int j = 1; j <= M; j++) {
            ll all = sum - a[i] + j;
            if (all % 2 == 0) {
                int h = all / 2;
                if (f2[h] || (h >= j && f2[h - j])) {
                    cnt[j]++;
                }
            }
        }
    }

    vector <int> save;
    for (int i = 1; i <= M; i++) 
        if (cnt[i] == n)
            save.pb(i);

    cout << sz(save) << '\n';
    for (auto x : save) 
        cout << x << " ";

    return 0;
}  
  
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 11 ms 3164 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 22 ms 3160 KB Output is correct
6 Correct 14 ms 3160 KB Output is correct
7 Correct 11 ms 3160 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 17 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 11 ms 3164 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 22 ms 3160 KB Output is correct
6 Correct 14 ms 3160 KB Output is correct
7 Correct 11 ms 3160 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 17 ms 3164 KB Output is correct
10 Correct 53 ms 3216 KB Output is correct
11 Correct 51 ms 3160 KB Output is correct
12 Correct 48 ms 3164 KB Output is correct
13 Correct 44 ms 3188 KB Output is correct
14 Correct 50 ms 3188 KB Output is correct
15 Correct 47 ms 3196 KB Output is correct
16 Correct 50 ms 3164 KB Output is correct
17 Correct 30 ms 3164 KB Output is correct
18 Correct 40 ms 3164 KB Output is correct
19 Correct 44 ms 3164 KB Output is correct
20 Correct 48 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 11 ms 3164 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 22 ms 3160 KB Output is correct
6 Correct 14 ms 3160 KB Output is correct
7 Correct 11 ms 3160 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 17 ms 3164 KB Output is correct
10 Correct 53 ms 3216 KB Output is correct
11 Correct 51 ms 3160 KB Output is correct
12 Correct 48 ms 3164 KB Output is correct
13 Correct 44 ms 3188 KB Output is correct
14 Correct 50 ms 3188 KB Output is correct
15 Correct 47 ms 3196 KB Output is correct
16 Correct 50 ms 3164 KB Output is correct
17 Correct 30 ms 3164 KB Output is correct
18 Correct 40 ms 3164 KB Output is correct
19 Correct 44 ms 3164 KB Output is correct
20 Correct 48 ms 3164 KB Output is correct
21 Correct 104 ms 3668 KB Output is correct
22 Correct 124 ms 3416 KB Output is correct
23 Correct 81 ms 3160 KB Output is correct
24 Correct 152 ms 3160 KB Output is correct
25 Correct 152 ms 3224 KB Output is correct
26 Correct 161 ms 3160 KB Output is correct
27 Correct 158 ms 3160 KB Output is correct
28 Correct 158 ms 3184 KB Output is correct
29 Correct 159 ms 3160 KB Output is correct
30 Correct 159 ms 3416 KB Output is correct
31 Correct 169 ms 3224 KB Output is correct
32 Correct 159 ms 3164 KB Output is correct
33 Correct 157 ms 3192 KB Output is correct
34 Correct 157 ms 3228 KB Output is correct
35 Correct 160 ms 3164 KB Output is correct
36 Correct 161 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 11 ms 3164 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 22 ms 3160 KB Output is correct
6 Correct 14 ms 3160 KB Output is correct
7 Correct 11 ms 3160 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 17 ms 3164 KB Output is correct
10 Correct 53 ms 3216 KB Output is correct
11 Correct 51 ms 3160 KB Output is correct
12 Correct 48 ms 3164 KB Output is correct
13 Correct 44 ms 3188 KB Output is correct
14 Correct 50 ms 3188 KB Output is correct
15 Correct 47 ms 3196 KB Output is correct
16 Correct 50 ms 3164 KB Output is correct
17 Correct 30 ms 3164 KB Output is correct
18 Correct 40 ms 3164 KB Output is correct
19 Correct 44 ms 3164 KB Output is correct
20 Correct 48 ms 3164 KB Output is correct
21 Correct 104 ms 3668 KB Output is correct
22 Correct 124 ms 3416 KB Output is correct
23 Correct 81 ms 3160 KB Output is correct
24 Correct 152 ms 3160 KB Output is correct
25 Correct 152 ms 3224 KB Output is correct
26 Correct 161 ms 3160 KB Output is correct
27 Correct 158 ms 3160 KB Output is correct
28 Correct 158 ms 3184 KB Output is correct
29 Correct 159 ms 3160 KB Output is correct
30 Correct 159 ms 3416 KB Output is correct
31 Correct 169 ms 3224 KB Output is correct
32 Correct 159 ms 3164 KB Output is correct
33 Correct 157 ms 3192 KB Output is correct
34 Correct 157 ms 3228 KB Output is correct
35 Correct 160 ms 3164 KB Output is correct
36 Correct 161 ms 3204 KB Output is correct
37 Correct 334 ms 3204 KB Output is correct
38 Correct 332 ms 3188 KB Output is correct
39 Correct 390 ms 3412 KB Output is correct
40 Correct 460 ms 3448 KB Output is correct
41 Correct 425 ms 3192 KB Output is correct
42 Correct 459 ms 3408 KB Output is correct
43 Correct 437 ms 3664 KB Output is correct
44 Correct 450 ms 3620 KB Output is correct
45 Correct 449 ms 3704 KB Output is correct
46 Correct 436 ms 3164 KB Output is correct
47 Correct 426 ms 3412 KB Output is correct
48 Correct 443 ms 3664 KB Output is correct
49 Correct 422 ms 3592 KB Output is correct
50 Correct 424 ms 3444 KB Output is correct
51 Correct 420 ms 3312 KB Output is correct
52 Correct 496 ms 3664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 11 ms 3164 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 22 ms 3160 KB Output is correct
6 Correct 14 ms 3160 KB Output is correct
7 Correct 11 ms 3160 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 17 ms 3164 KB Output is correct
10 Correct 53 ms 3216 KB Output is correct
11 Correct 51 ms 3160 KB Output is correct
12 Correct 48 ms 3164 KB Output is correct
13 Correct 44 ms 3188 KB Output is correct
14 Correct 50 ms 3188 KB Output is correct
15 Correct 47 ms 3196 KB Output is correct
16 Correct 50 ms 3164 KB Output is correct
17 Correct 30 ms 3164 KB Output is correct
18 Correct 40 ms 3164 KB Output is correct
19 Correct 44 ms 3164 KB Output is correct
20 Correct 48 ms 3164 KB Output is correct
21 Correct 104 ms 3668 KB Output is correct
22 Correct 124 ms 3416 KB Output is correct
23 Correct 81 ms 3160 KB Output is correct
24 Correct 152 ms 3160 KB Output is correct
25 Correct 152 ms 3224 KB Output is correct
26 Correct 161 ms 3160 KB Output is correct
27 Correct 158 ms 3160 KB Output is correct
28 Correct 158 ms 3184 KB Output is correct
29 Correct 159 ms 3160 KB Output is correct
30 Correct 159 ms 3416 KB Output is correct
31 Correct 169 ms 3224 KB Output is correct
32 Correct 159 ms 3164 KB Output is correct
33 Correct 157 ms 3192 KB Output is correct
34 Correct 157 ms 3228 KB Output is correct
35 Correct 160 ms 3164 KB Output is correct
36 Correct 161 ms 3204 KB Output is correct
37 Correct 334 ms 3204 KB Output is correct
38 Correct 332 ms 3188 KB Output is correct
39 Correct 390 ms 3412 KB Output is correct
40 Correct 460 ms 3448 KB Output is correct
41 Correct 425 ms 3192 KB Output is correct
42 Correct 459 ms 3408 KB Output is correct
43 Correct 437 ms 3664 KB Output is correct
44 Correct 450 ms 3620 KB Output is correct
45 Correct 449 ms 3704 KB Output is correct
46 Correct 436 ms 3164 KB Output is correct
47 Correct 426 ms 3412 KB Output is correct
48 Correct 443 ms 3664 KB Output is correct
49 Correct 422 ms 3592 KB Output is correct
50 Correct 424 ms 3444 KB Output is correct
51 Correct 420 ms 3312 KB Output is correct
52 Correct 496 ms 3664 KB Output is correct
53 Correct 541 ms 3712 KB Output is correct
54 Correct 631 ms 3624 KB Output is correct
55 Correct 709 ms 3760 KB Output is correct
56 Correct 558 ms 3696 KB Output is correct
57 Correct 724 ms 3832 KB Output is correct
58 Correct 634 ms 3700 KB Output is correct
59 Correct 662 ms 3716 KB Output is correct
60 Correct 633 ms 3188 KB Output is correct
61 Correct 679 ms 3828 KB Output is correct
62 Correct 630 ms 3828 KB Output is correct
63 Correct 636 ms 3796 KB Output is correct
64 Correct 622 ms 4060 KB Output is correct
65 Correct 499 ms 3444 KB Output is correct
66 Correct 504 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3164 KB Output is correct
2 Correct 11 ms 3164 KB Output is correct
3 Correct 4 ms 3164 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 22 ms 3160 KB Output is correct
6 Correct 14 ms 3160 KB Output is correct
7 Correct 11 ms 3160 KB Output is correct
8 Correct 20 ms 3164 KB Output is correct
9 Correct 17 ms 3164 KB Output is correct
10 Correct 53 ms 3216 KB Output is correct
11 Correct 51 ms 3160 KB Output is correct
12 Correct 48 ms 3164 KB Output is correct
13 Correct 44 ms 3188 KB Output is correct
14 Correct 50 ms 3188 KB Output is correct
15 Correct 47 ms 3196 KB Output is correct
16 Correct 50 ms 3164 KB Output is correct
17 Correct 30 ms 3164 KB Output is correct
18 Correct 40 ms 3164 KB Output is correct
19 Correct 44 ms 3164 KB Output is correct
20 Correct 48 ms 3164 KB Output is correct
21 Correct 104 ms 3668 KB Output is correct
22 Correct 124 ms 3416 KB Output is correct
23 Correct 81 ms 3160 KB Output is correct
24 Correct 152 ms 3160 KB Output is correct
25 Correct 152 ms 3224 KB Output is correct
26 Correct 161 ms 3160 KB Output is correct
27 Correct 158 ms 3160 KB Output is correct
28 Correct 158 ms 3184 KB Output is correct
29 Correct 159 ms 3160 KB Output is correct
30 Correct 159 ms 3416 KB Output is correct
31 Correct 169 ms 3224 KB Output is correct
32 Correct 159 ms 3164 KB Output is correct
33 Correct 157 ms 3192 KB Output is correct
34 Correct 157 ms 3228 KB Output is correct
35 Correct 160 ms 3164 KB Output is correct
36 Correct 161 ms 3204 KB Output is correct
37 Correct 334 ms 3204 KB Output is correct
38 Correct 332 ms 3188 KB Output is correct
39 Correct 390 ms 3412 KB Output is correct
40 Correct 460 ms 3448 KB Output is correct
41 Correct 425 ms 3192 KB Output is correct
42 Correct 459 ms 3408 KB Output is correct
43 Correct 437 ms 3664 KB Output is correct
44 Correct 450 ms 3620 KB Output is correct
45 Correct 449 ms 3704 KB Output is correct
46 Correct 436 ms 3164 KB Output is correct
47 Correct 426 ms 3412 KB Output is correct
48 Correct 443 ms 3664 KB Output is correct
49 Correct 422 ms 3592 KB Output is correct
50 Correct 424 ms 3444 KB Output is correct
51 Correct 420 ms 3312 KB Output is correct
52 Correct 496 ms 3664 KB Output is correct
53 Correct 541 ms 3712 KB Output is correct
54 Correct 631 ms 3624 KB Output is correct
55 Correct 709 ms 3760 KB Output is correct
56 Correct 558 ms 3696 KB Output is correct
57 Correct 724 ms 3832 KB Output is correct
58 Correct 634 ms 3700 KB Output is correct
59 Correct 662 ms 3716 KB Output is correct
60 Correct 633 ms 3188 KB Output is correct
61 Correct 679 ms 3828 KB Output is correct
62 Correct 630 ms 3828 KB Output is correct
63 Correct 636 ms 3796 KB Output is correct
64 Correct 622 ms 4060 KB Output is correct
65 Correct 499 ms 3444 KB Output is correct
66 Correct 504 ms 3412 KB Output is correct
67 Correct 771 ms 4128 KB Output is correct
68 Correct 535 ms 3188 KB Output is correct
69 Execution timed out 1052 ms 3188 KB Time limit exceeded
70 Halted 0 ms 0 KB -