답안 #982165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982165 2024-05-14T01:41:57 Z LOLOLO Bootfall (IZhO17_bootfall) C++17
65 / 100
644 ms 2724 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) / 2;
int f[M + 10], f2[M + 10], cnt[M + 10], mod = 1e8 + 3;
int a[N];

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

    f[0] = 1;

    int 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]]);
                while (f2[j] < 0)
                    f2[j] += mod;
            } else {
                f2[j] = f[j]; 
            }
        }

        int odd = (sum - a[i]) % 2;
        for (int j = odd; j <= M; j += 2) {
            int 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 4 ms 1368 KB Output is correct
2 Correct 6 ms 1372 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 10 ms 1200 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 6 ms 1448 KB Output is correct
8 Correct 12 ms 1372 KB Output is correct
9 Correct 10 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 6 ms 1372 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 10 ms 1200 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 6 ms 1448 KB Output is correct
8 Correct 12 ms 1372 KB Output is correct
9 Correct 10 ms 1368 KB Output is correct
10 Correct 24 ms 1368 KB Output is correct
11 Correct 25 ms 1204 KB Output is correct
12 Correct 26 ms 1372 KB Output is correct
13 Correct 21 ms 1372 KB Output is correct
14 Correct 23 ms 1204 KB Output is correct
15 Correct 22 ms 1372 KB Output is correct
16 Correct 24 ms 1208 KB Output is correct
17 Correct 15 ms 1204 KB Output is correct
18 Correct 20 ms 1372 KB Output is correct
19 Correct 20 ms 1372 KB Output is correct
20 Correct 24 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 6 ms 1372 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 10 ms 1200 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 6 ms 1448 KB Output is correct
8 Correct 12 ms 1372 KB Output is correct
9 Correct 10 ms 1368 KB Output is correct
10 Correct 24 ms 1368 KB Output is correct
11 Correct 25 ms 1204 KB Output is correct
12 Correct 26 ms 1372 KB Output is correct
13 Correct 21 ms 1372 KB Output is correct
14 Correct 23 ms 1204 KB Output is correct
15 Correct 22 ms 1372 KB Output is correct
16 Correct 24 ms 1208 KB Output is correct
17 Correct 15 ms 1204 KB Output is correct
18 Correct 20 ms 1372 KB Output is correct
19 Correct 20 ms 1372 KB Output is correct
20 Correct 24 ms 1372 KB Output is correct
21 Correct 50 ms 1360 KB Output is correct
22 Correct 58 ms 1368 KB Output is correct
23 Correct 39 ms 1448 KB Output is correct
24 Correct 75 ms 1608 KB Output is correct
25 Correct 74 ms 1364 KB Output is correct
26 Correct 86 ms 1452 KB Output is correct
27 Correct 78 ms 1436 KB Output is correct
28 Correct 78 ms 1452 KB Output is correct
29 Correct 78 ms 1364 KB Output is correct
30 Correct 78 ms 1368 KB Output is correct
31 Correct 79 ms 1360 KB Output is correct
32 Correct 80 ms 1360 KB Output is correct
33 Correct 84 ms 1696 KB Output is correct
34 Correct 76 ms 1452 KB Output is correct
35 Correct 79 ms 1364 KB Output is correct
36 Correct 80 ms 1448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 6 ms 1372 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 10 ms 1200 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 6 ms 1448 KB Output is correct
8 Correct 12 ms 1372 KB Output is correct
9 Correct 10 ms 1368 KB Output is correct
10 Correct 24 ms 1368 KB Output is correct
11 Correct 25 ms 1204 KB Output is correct
12 Correct 26 ms 1372 KB Output is correct
13 Correct 21 ms 1372 KB Output is correct
14 Correct 23 ms 1204 KB Output is correct
15 Correct 22 ms 1372 KB Output is correct
16 Correct 24 ms 1208 KB Output is correct
17 Correct 15 ms 1204 KB Output is correct
18 Correct 20 ms 1372 KB Output is correct
19 Correct 20 ms 1372 KB Output is correct
20 Correct 24 ms 1372 KB Output is correct
21 Correct 50 ms 1360 KB Output is correct
22 Correct 58 ms 1368 KB Output is correct
23 Correct 39 ms 1448 KB Output is correct
24 Correct 75 ms 1608 KB Output is correct
25 Correct 74 ms 1364 KB Output is correct
26 Correct 86 ms 1452 KB Output is correct
27 Correct 78 ms 1436 KB Output is correct
28 Correct 78 ms 1452 KB Output is correct
29 Correct 78 ms 1364 KB Output is correct
30 Correct 78 ms 1368 KB Output is correct
31 Correct 79 ms 1360 KB Output is correct
32 Correct 80 ms 1360 KB Output is correct
33 Correct 84 ms 1696 KB Output is correct
34 Correct 76 ms 1452 KB Output is correct
35 Correct 79 ms 1364 KB Output is correct
36 Correct 80 ms 1448 KB Output is correct
37 Correct 168 ms 1448 KB Output is correct
38 Correct 168 ms 1620 KB Output is correct
39 Correct 189 ms 1620 KB Output is correct
40 Correct 242 ms 1544 KB Output is correct
41 Correct 207 ms 1684 KB Output is correct
42 Correct 221 ms 1616 KB Output is correct
43 Correct 241 ms 1876 KB Output is correct
44 Correct 244 ms 1896 KB Output is correct
45 Correct 249 ms 1876 KB Output is correct
46 Correct 221 ms 1436 KB Output is correct
47 Correct 223 ms 1704 KB Output is correct
48 Correct 240 ms 1872 KB Output is correct
49 Correct 230 ms 1616 KB Output is correct
50 Correct 225 ms 1620 KB Output is correct
51 Correct 228 ms 1624 KB Output is correct
52 Correct 277 ms 1944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 6 ms 1372 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 10 ms 1200 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 6 ms 1448 KB Output is correct
8 Correct 12 ms 1372 KB Output is correct
9 Correct 10 ms 1368 KB Output is correct
10 Correct 24 ms 1368 KB Output is correct
11 Correct 25 ms 1204 KB Output is correct
12 Correct 26 ms 1372 KB Output is correct
13 Correct 21 ms 1372 KB Output is correct
14 Correct 23 ms 1204 KB Output is correct
15 Correct 22 ms 1372 KB Output is correct
16 Correct 24 ms 1208 KB Output is correct
17 Correct 15 ms 1204 KB Output is correct
18 Correct 20 ms 1372 KB Output is correct
19 Correct 20 ms 1372 KB Output is correct
20 Correct 24 ms 1372 KB Output is correct
21 Correct 50 ms 1360 KB Output is correct
22 Correct 58 ms 1368 KB Output is correct
23 Correct 39 ms 1448 KB Output is correct
24 Correct 75 ms 1608 KB Output is correct
25 Correct 74 ms 1364 KB Output is correct
26 Correct 86 ms 1452 KB Output is correct
27 Correct 78 ms 1436 KB Output is correct
28 Correct 78 ms 1452 KB Output is correct
29 Correct 78 ms 1364 KB Output is correct
30 Correct 78 ms 1368 KB Output is correct
31 Correct 79 ms 1360 KB Output is correct
32 Correct 80 ms 1360 KB Output is correct
33 Correct 84 ms 1696 KB Output is correct
34 Correct 76 ms 1452 KB Output is correct
35 Correct 79 ms 1364 KB Output is correct
36 Correct 80 ms 1448 KB Output is correct
37 Correct 168 ms 1448 KB Output is correct
38 Correct 168 ms 1620 KB Output is correct
39 Correct 189 ms 1620 KB Output is correct
40 Correct 242 ms 1544 KB Output is correct
41 Correct 207 ms 1684 KB Output is correct
42 Correct 221 ms 1616 KB Output is correct
43 Correct 241 ms 1876 KB Output is correct
44 Correct 244 ms 1896 KB Output is correct
45 Correct 249 ms 1876 KB Output is correct
46 Correct 221 ms 1436 KB Output is correct
47 Correct 223 ms 1704 KB Output is correct
48 Correct 240 ms 1872 KB Output is correct
49 Correct 230 ms 1616 KB Output is correct
50 Correct 225 ms 1620 KB Output is correct
51 Correct 228 ms 1624 KB Output is correct
52 Correct 277 ms 1944 KB Output is correct
53 Correct 287 ms 1848 KB Output is correct
54 Correct 350 ms 1888 KB Output is correct
55 Correct 421 ms 2340 KB Output is correct
56 Correct 304 ms 1876 KB Output is correct
57 Correct 435 ms 2520 KB Output is correct
58 Correct 357 ms 1876 KB Output is correct
59 Correct 380 ms 2104 KB Output is correct
60 Correct 355 ms 1436 KB Output is correct
61 Correct 392 ms 2264 KB Output is correct
62 Correct 375 ms 2260 KB Output is correct
63 Correct 384 ms 2332 KB Output is correct
64 Correct 372 ms 2216 KB Output is correct
65 Correct 243 ms 1440 KB Output is correct
66 Correct 250 ms 1692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1368 KB Output is correct
2 Correct 6 ms 1372 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 10 ms 1200 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 6 ms 1448 KB Output is correct
8 Correct 12 ms 1372 KB Output is correct
9 Correct 10 ms 1368 KB Output is correct
10 Correct 24 ms 1368 KB Output is correct
11 Correct 25 ms 1204 KB Output is correct
12 Correct 26 ms 1372 KB Output is correct
13 Correct 21 ms 1372 KB Output is correct
14 Correct 23 ms 1204 KB Output is correct
15 Correct 22 ms 1372 KB Output is correct
16 Correct 24 ms 1208 KB Output is correct
17 Correct 15 ms 1204 KB Output is correct
18 Correct 20 ms 1372 KB Output is correct
19 Correct 20 ms 1372 KB Output is correct
20 Correct 24 ms 1372 KB Output is correct
21 Correct 50 ms 1360 KB Output is correct
22 Correct 58 ms 1368 KB Output is correct
23 Correct 39 ms 1448 KB Output is correct
24 Correct 75 ms 1608 KB Output is correct
25 Correct 74 ms 1364 KB Output is correct
26 Correct 86 ms 1452 KB Output is correct
27 Correct 78 ms 1436 KB Output is correct
28 Correct 78 ms 1452 KB Output is correct
29 Correct 78 ms 1364 KB Output is correct
30 Correct 78 ms 1368 KB Output is correct
31 Correct 79 ms 1360 KB Output is correct
32 Correct 80 ms 1360 KB Output is correct
33 Correct 84 ms 1696 KB Output is correct
34 Correct 76 ms 1452 KB Output is correct
35 Correct 79 ms 1364 KB Output is correct
36 Correct 80 ms 1448 KB Output is correct
37 Correct 168 ms 1448 KB Output is correct
38 Correct 168 ms 1620 KB Output is correct
39 Correct 189 ms 1620 KB Output is correct
40 Correct 242 ms 1544 KB Output is correct
41 Correct 207 ms 1684 KB Output is correct
42 Correct 221 ms 1616 KB Output is correct
43 Correct 241 ms 1876 KB Output is correct
44 Correct 244 ms 1896 KB Output is correct
45 Correct 249 ms 1876 KB Output is correct
46 Correct 221 ms 1436 KB Output is correct
47 Correct 223 ms 1704 KB Output is correct
48 Correct 240 ms 1872 KB Output is correct
49 Correct 230 ms 1616 KB Output is correct
50 Correct 225 ms 1620 KB Output is correct
51 Correct 228 ms 1624 KB Output is correct
52 Correct 277 ms 1944 KB Output is correct
53 Correct 287 ms 1848 KB Output is correct
54 Correct 350 ms 1888 KB Output is correct
55 Correct 421 ms 2340 KB Output is correct
56 Correct 304 ms 1876 KB Output is correct
57 Correct 435 ms 2520 KB Output is correct
58 Correct 357 ms 1876 KB Output is correct
59 Correct 380 ms 2104 KB Output is correct
60 Correct 355 ms 1436 KB Output is correct
61 Correct 392 ms 2264 KB Output is correct
62 Correct 375 ms 2260 KB Output is correct
63 Correct 384 ms 2332 KB Output is correct
64 Correct 372 ms 2216 KB Output is correct
65 Correct 243 ms 1440 KB Output is correct
66 Correct 250 ms 1692 KB Output is correct
67 Correct 445 ms 2260 KB Output is correct
68 Correct 268 ms 856 KB Output is correct
69 Incorrect 644 ms 2724 KB Output isn't correct
70 Halted 0 ms 0 KB -