답안 #982145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982145 2024-05-14T01:01:47 Z LOLOLO Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 6952 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;
ll f[M + 10], f2[M], cnt[M], mod = 1e16 + 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) % 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;
}  
  
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5976 KB Output is correct
2 Correct 16 ms 5980 KB Output is correct
3 Correct 5 ms 3928 KB Output is correct
4 Correct 12 ms 5976 KB Output is correct
5 Correct 30 ms 6148 KB Output is correct
6 Correct 22 ms 5976 KB Output is correct
7 Correct 18 ms 5980 KB Output is correct
8 Correct 31 ms 6152 KB Output is correct
9 Correct 26 ms 5980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5976 KB Output is correct
2 Correct 16 ms 5980 KB Output is correct
3 Correct 5 ms 3928 KB Output is correct
4 Correct 12 ms 5976 KB Output is correct
5 Correct 30 ms 6148 KB Output is correct
6 Correct 22 ms 5976 KB Output is correct
7 Correct 18 ms 5980 KB Output is correct
8 Correct 31 ms 6152 KB Output is correct
9 Correct 26 ms 5980 KB Output is correct
10 Correct 75 ms 5972 KB Output is correct
11 Correct 75 ms 5968 KB Output is correct
12 Correct 77 ms 5972 KB Output is correct
13 Correct 65 ms 5972 KB Output is correct
14 Correct 69 ms 5968 KB Output is correct
15 Correct 70 ms 5976 KB Output is correct
16 Correct 79 ms 6380 KB Output is correct
17 Correct 45 ms 6132 KB Output is correct
18 Correct 61 ms 6144 KB Output is correct
19 Correct 64 ms 6140 KB Output is correct
20 Correct 73 ms 5968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5976 KB Output is correct
2 Correct 16 ms 5980 KB Output is correct
3 Correct 5 ms 3928 KB Output is correct
4 Correct 12 ms 5976 KB Output is correct
5 Correct 30 ms 6148 KB Output is correct
6 Correct 22 ms 5976 KB Output is correct
7 Correct 18 ms 5980 KB Output is correct
8 Correct 31 ms 6152 KB Output is correct
9 Correct 26 ms 5980 KB Output is correct
10 Correct 75 ms 5972 KB Output is correct
11 Correct 75 ms 5968 KB Output is correct
12 Correct 77 ms 5972 KB Output is correct
13 Correct 65 ms 5972 KB Output is correct
14 Correct 69 ms 5968 KB Output is correct
15 Correct 70 ms 5976 KB Output is correct
16 Correct 79 ms 6380 KB Output is correct
17 Correct 45 ms 6132 KB Output is correct
18 Correct 61 ms 6144 KB Output is correct
19 Correct 64 ms 6140 KB Output is correct
20 Correct 73 ms 5968 KB Output is correct
21 Correct 154 ms 6124 KB Output is correct
22 Correct 178 ms 6228 KB Output is correct
23 Correct 121 ms 5968 KB Output is correct
24 Correct 234 ms 6204 KB Output is correct
25 Correct 225 ms 6220 KB Output is correct
26 Correct 239 ms 6204 KB Output is correct
27 Correct 238 ms 6128 KB Output is correct
28 Correct 240 ms 6228 KB Output is correct
29 Correct 237 ms 5968 KB Output is correct
30 Correct 240 ms 6392 KB Output is correct
31 Correct 239 ms 6120 KB Output is correct
32 Correct 239 ms 6164 KB Output is correct
33 Correct 243 ms 6208 KB Output is correct
34 Correct 237 ms 5968 KB Output is correct
35 Correct 239 ms 6204 KB Output is correct
36 Correct 241 ms 6224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5976 KB Output is correct
2 Correct 16 ms 5980 KB Output is correct
3 Correct 5 ms 3928 KB Output is correct
4 Correct 12 ms 5976 KB Output is correct
5 Correct 30 ms 6148 KB Output is correct
6 Correct 22 ms 5976 KB Output is correct
7 Correct 18 ms 5980 KB Output is correct
8 Correct 31 ms 6152 KB Output is correct
9 Correct 26 ms 5980 KB Output is correct
10 Correct 75 ms 5972 KB Output is correct
11 Correct 75 ms 5968 KB Output is correct
12 Correct 77 ms 5972 KB Output is correct
13 Correct 65 ms 5972 KB Output is correct
14 Correct 69 ms 5968 KB Output is correct
15 Correct 70 ms 5976 KB Output is correct
16 Correct 79 ms 6380 KB Output is correct
17 Correct 45 ms 6132 KB Output is correct
18 Correct 61 ms 6144 KB Output is correct
19 Correct 64 ms 6140 KB Output is correct
20 Correct 73 ms 5968 KB Output is correct
21 Correct 154 ms 6124 KB Output is correct
22 Correct 178 ms 6228 KB Output is correct
23 Correct 121 ms 5968 KB Output is correct
24 Correct 234 ms 6204 KB Output is correct
25 Correct 225 ms 6220 KB Output is correct
26 Correct 239 ms 6204 KB Output is correct
27 Correct 238 ms 6128 KB Output is correct
28 Correct 240 ms 6228 KB Output is correct
29 Correct 237 ms 5968 KB Output is correct
30 Correct 240 ms 6392 KB Output is correct
31 Correct 239 ms 6120 KB Output is correct
32 Correct 239 ms 6164 KB Output is correct
33 Correct 243 ms 6208 KB Output is correct
34 Correct 237 ms 5968 KB Output is correct
35 Correct 239 ms 6204 KB Output is correct
36 Correct 241 ms 6224 KB Output is correct
37 Correct 484 ms 6384 KB Output is correct
38 Correct 477 ms 6236 KB Output is correct
39 Correct 593 ms 6312 KB Output is correct
40 Correct 648 ms 6480 KB Output is correct
41 Correct 644 ms 6128 KB Output is correct
42 Correct 589 ms 6480 KB Output is correct
43 Correct 579 ms 6740 KB Output is correct
44 Correct 589 ms 6740 KB Output is correct
45 Correct 599 ms 6484 KB Output is correct
46 Correct 637 ms 6308 KB Output is correct
47 Correct 595 ms 6408 KB Output is correct
48 Correct 596 ms 6736 KB Output is correct
49 Correct 595 ms 6136 KB Output is correct
50 Correct 594 ms 6484 KB Output is correct
51 Correct 591 ms 6408 KB Output is correct
52 Correct 641 ms 6740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5976 KB Output is correct
2 Correct 16 ms 5980 KB Output is correct
3 Correct 5 ms 3928 KB Output is correct
4 Correct 12 ms 5976 KB Output is correct
5 Correct 30 ms 6148 KB Output is correct
6 Correct 22 ms 5976 KB Output is correct
7 Correct 18 ms 5980 KB Output is correct
8 Correct 31 ms 6152 KB Output is correct
9 Correct 26 ms 5980 KB Output is correct
10 Correct 75 ms 5972 KB Output is correct
11 Correct 75 ms 5968 KB Output is correct
12 Correct 77 ms 5972 KB Output is correct
13 Correct 65 ms 5972 KB Output is correct
14 Correct 69 ms 5968 KB Output is correct
15 Correct 70 ms 5976 KB Output is correct
16 Correct 79 ms 6380 KB Output is correct
17 Correct 45 ms 6132 KB Output is correct
18 Correct 61 ms 6144 KB Output is correct
19 Correct 64 ms 6140 KB Output is correct
20 Correct 73 ms 5968 KB Output is correct
21 Correct 154 ms 6124 KB Output is correct
22 Correct 178 ms 6228 KB Output is correct
23 Correct 121 ms 5968 KB Output is correct
24 Correct 234 ms 6204 KB Output is correct
25 Correct 225 ms 6220 KB Output is correct
26 Correct 239 ms 6204 KB Output is correct
27 Correct 238 ms 6128 KB Output is correct
28 Correct 240 ms 6228 KB Output is correct
29 Correct 237 ms 5968 KB Output is correct
30 Correct 240 ms 6392 KB Output is correct
31 Correct 239 ms 6120 KB Output is correct
32 Correct 239 ms 6164 KB Output is correct
33 Correct 243 ms 6208 KB Output is correct
34 Correct 237 ms 5968 KB Output is correct
35 Correct 239 ms 6204 KB Output is correct
36 Correct 241 ms 6224 KB Output is correct
37 Correct 484 ms 6384 KB Output is correct
38 Correct 477 ms 6236 KB Output is correct
39 Correct 593 ms 6312 KB Output is correct
40 Correct 648 ms 6480 KB Output is correct
41 Correct 644 ms 6128 KB Output is correct
42 Correct 589 ms 6480 KB Output is correct
43 Correct 579 ms 6740 KB Output is correct
44 Correct 589 ms 6740 KB Output is correct
45 Correct 599 ms 6484 KB Output is correct
46 Correct 637 ms 6308 KB Output is correct
47 Correct 595 ms 6408 KB Output is correct
48 Correct 596 ms 6736 KB Output is correct
49 Correct 595 ms 6136 KB Output is correct
50 Correct 594 ms 6484 KB Output is correct
51 Correct 591 ms 6408 KB Output is correct
52 Correct 641 ms 6740 KB Output is correct
53 Correct 730 ms 6560 KB Output is correct
54 Correct 828 ms 6564 KB Output is correct
55 Correct 834 ms 6872 KB Output is correct
56 Correct 726 ms 6636 KB Output is correct
57 Correct 827 ms 6952 KB Output is correct
58 Correct 828 ms 6640 KB Output is correct
59 Correct 826 ms 6696 KB Output is correct
60 Correct 831 ms 6120 KB Output is correct
61 Correct 840 ms 6872 KB Output is correct
62 Correct 754 ms 6696 KB Output is correct
63 Correct 756 ms 6872 KB Output is correct
64 Correct 742 ms 6804 KB Output is correct
65 Correct 752 ms 6304 KB Output is correct
66 Correct 740 ms 6344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5976 KB Output is correct
2 Correct 16 ms 5980 KB Output is correct
3 Correct 5 ms 3928 KB Output is correct
4 Correct 12 ms 5976 KB Output is correct
5 Correct 30 ms 6148 KB Output is correct
6 Correct 22 ms 5976 KB Output is correct
7 Correct 18 ms 5980 KB Output is correct
8 Correct 31 ms 6152 KB Output is correct
9 Correct 26 ms 5980 KB Output is correct
10 Correct 75 ms 5972 KB Output is correct
11 Correct 75 ms 5968 KB Output is correct
12 Correct 77 ms 5972 KB Output is correct
13 Correct 65 ms 5972 KB Output is correct
14 Correct 69 ms 5968 KB Output is correct
15 Correct 70 ms 5976 KB Output is correct
16 Correct 79 ms 6380 KB Output is correct
17 Correct 45 ms 6132 KB Output is correct
18 Correct 61 ms 6144 KB Output is correct
19 Correct 64 ms 6140 KB Output is correct
20 Correct 73 ms 5968 KB Output is correct
21 Correct 154 ms 6124 KB Output is correct
22 Correct 178 ms 6228 KB Output is correct
23 Correct 121 ms 5968 KB Output is correct
24 Correct 234 ms 6204 KB Output is correct
25 Correct 225 ms 6220 KB Output is correct
26 Correct 239 ms 6204 KB Output is correct
27 Correct 238 ms 6128 KB Output is correct
28 Correct 240 ms 6228 KB Output is correct
29 Correct 237 ms 5968 KB Output is correct
30 Correct 240 ms 6392 KB Output is correct
31 Correct 239 ms 6120 KB Output is correct
32 Correct 239 ms 6164 KB Output is correct
33 Correct 243 ms 6208 KB Output is correct
34 Correct 237 ms 5968 KB Output is correct
35 Correct 239 ms 6204 KB Output is correct
36 Correct 241 ms 6224 KB Output is correct
37 Correct 484 ms 6384 KB Output is correct
38 Correct 477 ms 6236 KB Output is correct
39 Correct 593 ms 6312 KB Output is correct
40 Correct 648 ms 6480 KB Output is correct
41 Correct 644 ms 6128 KB Output is correct
42 Correct 589 ms 6480 KB Output is correct
43 Correct 579 ms 6740 KB Output is correct
44 Correct 589 ms 6740 KB Output is correct
45 Correct 599 ms 6484 KB Output is correct
46 Correct 637 ms 6308 KB Output is correct
47 Correct 595 ms 6408 KB Output is correct
48 Correct 596 ms 6736 KB Output is correct
49 Correct 595 ms 6136 KB Output is correct
50 Correct 594 ms 6484 KB Output is correct
51 Correct 591 ms 6408 KB Output is correct
52 Correct 641 ms 6740 KB Output is correct
53 Correct 730 ms 6560 KB Output is correct
54 Correct 828 ms 6564 KB Output is correct
55 Correct 834 ms 6872 KB Output is correct
56 Correct 726 ms 6636 KB Output is correct
57 Correct 827 ms 6952 KB Output is correct
58 Correct 828 ms 6640 KB Output is correct
59 Correct 826 ms 6696 KB Output is correct
60 Correct 831 ms 6120 KB Output is correct
61 Correct 840 ms 6872 KB Output is correct
62 Correct 754 ms 6696 KB Output is correct
63 Correct 756 ms 6872 KB Output is correct
64 Correct 742 ms 6804 KB Output is correct
65 Correct 752 ms 6304 KB Output is correct
66 Correct 740 ms 6344 KB Output is correct
67 Correct 951 ms 6700 KB Output is correct
68 Correct 538 ms 4076 KB Output is correct
69 Execution timed out 1032 ms 6120 KB Time limit exceeded
70 Halted 0 ms 0 KB -