답안 #406823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406823 2021-05-18T05:43:51 Z 2qbingxuan Bali Sculptures (APIO15_sculpture) C++14
100 / 100
256 ms 384 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#ifdef local
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define pary(a...) danb(#a, a)
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
    int cnt = sizeof...(T);
    ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
template <typename T> void danb(const char *s, T L, T R) {
    std::cerr << "\033[1;32m[ " << s << " ] = [ ";
    for (int f = 0; L != R; ++L)
        std::cerr << (f++ ? ", " : "") << *L;
    std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define safe ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back

using namespace std;
using ll = int_fast64_t;
const int inf = 1e9;
const int mod = 1000000007;
const int maxn = 2025;
const int maxc = (1 << 18);

ll pre[maxn], a[maxn];
int n, A, B;
int mn[maxn], mx[maxn];
bool ok(ll mask) {
    mn[0] = mx[0] = 0;
    for (int i = 1; i <= n; i++) {
        mn[i] = inf;
        mx[i] = -inf;
        for (int j = 0; j < i; j++) if (!(mask & (pre[i] - pre[j]))) {
            mn[i] = min(mn[i], mn[j] + 1);
            mx[i] = max(mx[i], mx[j] + 1);
        }
    }
    return max(A, mn[n]) <= min(B, mx[n]);
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> A >> B;

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) pre[i+1] = pre[i] + a[i];

    assert(ok(0));
    ll ans = 0, U = (1LL << 51) - 1;
    for (ll s = 1LL << 50; s; s >>= 1) if (ok(ans + s)) ans += s;
    cout << (U ^ ans) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 320 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 312 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 324 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 312 KB Output is correct
36 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 316 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 204 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 2 ms 204 KB Output is correct
28 Correct 2 ms 204 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 ms 204 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 216 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 320 KB Output is correct
40 Correct 2 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 2 ms 332 KB Output is correct
49 Correct 2 ms 204 KB Output is correct
50 Correct 2 ms 332 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 2 ms 332 KB Output is correct
53 Correct 2 ms 208 KB Output is correct
54 Correct 2 ms 204 KB Output is correct
55 Correct 2 ms 312 KB Output is correct
56 Correct 1 ms 204 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 2 ms 320 KB Output is correct
59 Correct 2 ms 204 KB Output is correct
60 Correct 2 ms 204 KB Output is correct
61 Correct 2 ms 204 KB Output is correct
62 Correct 2 ms 204 KB Output is correct
63 Correct 2 ms 332 KB Output is correct
64 Correct 2 ms 204 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 2 ms 312 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 2 ms 204 KB Output is correct
70 Correct 2 ms 204 KB Output is correct
71 Correct 2 ms 204 KB Output is correct
72 Correct 2 ms 328 KB Output is correct
73 Correct 2 ms 312 KB Output is correct
74 Correct 2 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 2 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 312 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 2 ms 320 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 2 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 2 ms 204 KB Output is correct
39 Correct 2 ms 204 KB Output is correct
40 Correct 2 ms 204 KB Output is correct
41 Correct 3 ms 316 KB Output is correct
42 Correct 2 ms 204 KB Output is correct
43 Correct 2 ms 204 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 2 ms 204 KB Output is correct
46 Correct 2 ms 332 KB Output is correct
47 Correct 2 ms 204 KB Output is correct
48 Correct 2 ms 204 KB Output is correct
49 Correct 2 ms 332 KB Output is correct
50 Correct 2 ms 332 KB Output is correct
51 Correct 2 ms 320 KB Output is correct
52 Correct 20 ms 340 KB Output is correct
53 Correct 33 ms 316 KB Output is correct
54 Correct 60 ms 332 KB Output is correct
55 Correct 59 ms 320 KB Output is correct
56 Correct 226 ms 364 KB Output is correct
57 Correct 256 ms 360 KB Output is correct
58 Correct 228 ms 356 KB Output is correct
59 Correct 234 ms 360 KB Output is correct
60 Correct 235 ms 368 KB Output is correct
61 Correct 3 ms 204 KB Output is correct
62 Correct 38 ms 332 KB Output is correct
63 Correct 74 ms 332 KB Output is correct
64 Correct 58 ms 332 KB Output is correct
65 Correct 136 ms 332 KB Output is correct
66 Correct 168 ms 360 KB Output is correct
67 Correct 226 ms 364 KB Output is correct
68 Correct 229 ms 380 KB Output is correct
69 Correct 225 ms 332 KB Output is correct