結果
問題 | No.973 余興 |
ユーザー | kcvlex |
提出日時 | 2020-01-18 00:24:50 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,611 bytes |
コンパイル時間 | 1,652 ms |
コンパイル使用メモリ | 171,600 KB |
実行使用メモリ | 170,832 KB |
最終ジャッジ日時 | 2024-06-26 02:49:44 |
合計ジャッジ時間 | 20,825 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 486 ms
130,084 KB |
testcase_06 | AC | 449 ms
130,848 KB |
testcase_07 | AC | 412 ms
131,036 KB |
testcase_08 | AC | 595 ms
131,896 KB |
testcase_09 | AC | 446 ms
131,264 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 278 ms
116,536 KB |
testcase_14 | WA | - |
testcase_15 | AC | 27 ms
40,492 KB |
testcase_16 | AC | 28 ms
37,896 KB |
testcase_17 | WA | - |
testcase_18 | AC | 23 ms
34,080 KB |
testcase_19 | AC | 25 ms
30,904 KB |
testcase_20 | AC | 20 ms
33,716 KB |
testcase_21 | AC | 23 ms
39,724 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 23 ms
29,140 KB |
testcase_29 | WA | - |
testcase_30 | AC | 606 ms
157,864 KB |
testcase_31 | AC | 601 ms
158,128 KB |
testcase_32 | AC | 598 ms
159,788 KB |
testcase_33 | AC | 606 ms
159,784 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 572 ms
157,652 KB |
testcase_37 | AC | 579 ms
158,008 KB |
testcase_38 | WA | - |
testcase_39 | AC | 588 ms
159,672 KB |
testcase_40 | AC | 3 ms
6,944 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 3 ms
6,940 KB |
testcase_43 | AC | 3 ms
7,684 KB |
testcase_44 | WA | - |
testcase_45 | AC | 4 ms
11,856 KB |
testcase_46 | WA | - |
testcase_47 | AC | 89 ms
144,744 KB |
testcase_48 | WA | - |
testcase_49 | AC | 92 ms
141,756 KB |
testcase_50 | WA | - |
testcase_51 | AC | 91 ms
144,232 KB |
testcase_52 | AC | 1,092 ms
167,692 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
ソースコード
// #define DEBUGGING #include <bits/stdc++.h> #define endl '\n' #define ALL(V) (V).begin(), (V).end() #define ALLR(V) (V).rbegin(), (V).rend() using ll = std::int64_t; using ull = std::uint64_t; using PLL = std::pair<ll, ll>; using TLL = std::tuple<ll, ll, ll>; template <typename T> using V = std::vector<T>; template <typename T> using VV = V<V<T>>; template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); } template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); } namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } #define mv_rec make_v(init, tail...) template <typename T> T make_v(T init) { return init; } template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); } #undef mv_rec using namespace std; #ifdef DEBUGGING #include "../../debug/debug.cpp" #else #define DEBUG(...) 0 #define DEBUG_SEPARATOR_LINE 0 #endif const size_t SIZE = 5010; bool calced[SIZE][SIZE][2]; int cnt_r[SIZE], cnt_l[SIZE]; int A[SIZE]; int N, X; struct Bit { int *data; int id_ele = 0; Bit() : Bit(nullptr) { } Bit(int *data) : data(data) { } int sum(int pos) { int ret = id_ele; for(; 0 < pos; pos -= pos & -pos) ret += data[pos]; return ret; } int sum(int l, int r) { if (r <= l) return 0; return sum(r) - sum(l); } void add(int pos, int delta) { for(++pos; pos < SIZE; pos += pos & -pos) data[pos] += delta; } }; void shaku(int max_v[]) { int l = 0, r = 0; int sum = 0; for (int l = 0; l < N; l++) { while (r < N && sum + A[r] <= X) { sum += A[r]; r++; } max_v[l] = r - l; sum -= A[l]; } } int bit_arr[2][SIZE][SIZE]; Bit bit_l[SIZE], bit_r[SIZE]; int main() { cin >> N >> X; for (int i = 0; i < N; i++) cin >> A[i]; shaku(cnt_r); reverse(A, A + N); shaku(cnt_l); reverse(A, A + N); reverse(cnt_l, cnt_l + N); V<Bit> bit_l(N), bit_r(N); for (ll i = 0; i < N; i++) { bit_l[i] = Bit(bit_arr[0][i]); bit_r[i] = Bit(bit_arr[1][i]); } int suma[SIZE]; for (int i = 0; i < N; i++) suma[i + 1] = suma[i] + A[i]; for (int len = 1; len <= N; len++) { for (int l = 0; l + len - 1 < N; l++) { int r = l + len - 1; if (suma[r + 1] - suma[l] <= X) continue; { int cnt = bit_r[r].sum(l + 1, l + cnt_r[l]); if (cnt < cnt_r[l] - 1) bit_l[l].add(r, 1); } { int cnt = bit_l[l].sum(r - cnt_l[r] + 1, r); if (cnt < cnt_l[r] - 1) bit_r[r].add(l, 1); } } } cout << (bit_l[0].sum(N - 1, N) == 1 ? "A" : "B") << endl; return 0; }