답안 #563220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563220 2022-05-16T14:09:25 Z Cyanmond Bali Sculptures (APIO15_sculpture) C++17
100 / 100
337 ms 348 KB
#include <bits/stdc++.h>

using namespace std;
using i64 = int64_t;

constexpr int inf = 1 << 25;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP3(i, l, r) for (int i = (l); i < (r); ++i)
#define RVP(i, n) for (int i = (n - 1); i >= 0; --i)

#define ALL(x) (x).begin(), (x).end()

template <typename T> void chmax(T &a, const T b) {
    if (a < b) a = b;
}
template <typename T> void chmin(T &a, const T b) {
    if (a > b) a = b;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    ++B;
    vector<i64> Y(N);
    for (auto &e : Y) cin >> e;
    vector<i64> Yc(N + 1);
    REP(i, N) Yc[i + 1] = Yc[i] + Y[i];
    auto sum = [&Yc](int l, int r) { return Yc[r] - Yc[l]; };

    i64 ans = 0;
    RVP(b, 50) {
        vector<int> dpmin(N + 1, inf), dpmax(N + 1, -inf);
        dpmin[0] = dpmax[0] = 0;
        REP(i, N) {
            REP3(j, i + 1, N + 1) {
                const i64 s = sum(i, j);
                if (s & (1ll << b)) continue;
                const i64 t = s & (((1ll << 51) - 1) - ((1ll << b) - 1));
                if ((t & ans) != t) continue;
                chmin(dpmin[j], dpmin[i] + 1);
                chmax(dpmax[j], dpmax[i] + 1);
            }
        }
        const int k_l = dpmin[N], k_r = dpmax[N] + 1;
        if (max(A, k_l) >= min(B, k_r)) {
            ans |= 1ll << b;
        }
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 296 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 308 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 300 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 304 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 1 ms 216 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 220 KB Output is correct
11 Correct 1 ms 216 KB Output is correct
12 Correct 1 ms 220 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 1 ms 216 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 1 ms 220 KB Output is correct
22 Correct 1 ms 216 KB Output is correct
23 Correct 1 ms 224 KB Output is correct
24 Correct 1 ms 224 KB Output is correct
25 Correct 1 ms 216 KB Output is correct
26 Correct 1 ms 216 KB Output is correct
27 Correct 1 ms 292 KB Output is correct
28 Correct 1 ms 220 KB Output is correct
29 Correct 1 ms 220 KB Output is correct
30 Correct 1 ms 216 KB Output is correct
31 Correct 1 ms 216 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 216 KB Output is correct
6 Correct 1 ms 216 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 216 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 216 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 220 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 300 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 304 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 300 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 296 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 300 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 2 ms 212 KB Output is correct
58 Correct 1 ms 300 KB Output is correct
59 Correct 2 ms 212 KB Output is correct
60 Correct 1 ms 296 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 300 KB Output is correct
66 Correct 1 ms 256 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 2 ms 212 KB Output is correct
69 Correct 2 ms 212 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 296 KB Output is correct
73 Correct 1 ms 212 KB Output is correct
74 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 300 KB Output is correct
27 Correct 1 ms 300 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 1 ms 296 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 296 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 296 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 2 ms 300 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 212 KB Output is correct
46 Correct 2 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 296 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 2 ms 212 KB Output is correct
52 Correct 27 ms 212 KB Output is correct
53 Correct 43 ms 320 KB Output is correct
54 Correct 86 ms 212 KB Output is correct
55 Correct 77 ms 316 KB Output is correct
56 Correct 337 ms 348 KB Output is correct
57 Correct 327 ms 340 KB Output is correct
58 Correct 187 ms 340 KB Output is correct
59 Correct 126 ms 344 KB Output is correct
60 Correct 140 ms 340 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 43 ms 300 KB Output is correct
63 Correct 76 ms 308 KB Output is correct
64 Correct 74 ms 312 KB Output is correct
65 Correct 138 ms 340 KB Output is correct
66 Correct 219 ms 332 KB Output is correct
67 Correct 261 ms 340 KB Output is correct
68 Correct 256 ms 344 KB Output is correct
69 Correct 292 ms 340 KB Output is correct