結果
問題 | No.973 余興 |
ユーザー | kcvlex |
提出日時 | 2020-01-18 01:26:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,815 bytes |
コンパイル時間 | 1,719 ms |
コンパイル使用メモリ | 170,268 KB |
実行使用メモリ | 199,068 KB |
最終ジャッジ日時 | 2024-06-26 04:49:38 |
合計ジャッジ時間 | 38,637 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 766 ms
71,424 KB |
testcase_06 | AC | 767 ms
71,936 KB |
testcase_07 | AC | 772 ms
71,680 KB |
testcase_08 | AC | 764 ms
71,552 KB |
testcase_09 | AC | 761 ms
72,192 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 400 ms
80,128 KB |
testcase_14 | WA | - |
testcase_15 | AC | 35 ms
24,832 KB |
testcase_16 | AC | 36 ms
24,960 KB |
testcase_17 | WA | - |
testcase_18 | AC | 29 ms
22,784 KB |
testcase_19 | AC | 30 ms
22,912 KB |
testcase_20 | AC | 26 ms
20,352 KB |
testcase_21 | AC | 35 ms
24,576 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 29 ms
22,528 KB |
testcase_29 | WA | - |
testcase_30 | AC | 1,201 ms
116,096 KB |
testcase_31 | AC | 1,195 ms
115,840 KB |
testcase_32 | AC | 1,205 ms
115,968 KB |
testcase_33 | AC | 1,172 ms
116,096 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 1,128 ms
115,072 KB |
testcase_37 | AC | 1,177 ms
115,072 KB |
testcase_38 | WA | - |
testcase_39 | AC | 1,193 ms
115,584 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | WA | - |
testcase_45 | AC | 4 ms
6,016 KB |
testcase_46 | WA | - |
testcase_47 | AC | 1,206 ms
113,792 KB |
testcase_48 | WA | - |
testcase_49 | AC | 1,100 ms
110,336 KB |
testcase_50 | WA | - |
testcase_51 | AC | 1,188 ms
113,664 KB |
testcase_52 | AC | 1,103 ms
114,432 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; 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(--pos; 0 < pos; pos -= pos & -pos) ret += data[pos]; return ret; } int sum(int l, int r) { return sum(r + 1) - sum(l); } void add(int pos, int delta) { for(; pos < SIZE; pos += pos & -pos) data[pos] += delta; } }; int bit_arr[2][SIZE][SIZE]; Bit bit_l[SIZE], bit_r[SIZE]; int cnt_l[SIZE], cnt_r[SIZE]; int A[SIZE]; int N, X; int main() { cin >> N >> X; for (int i = 0; i < N; i++) cin >> A[i]; auto make_cnt = [&](int cnt_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++; } cnt_v[l] = r - l; sum -= A[l]; } }; make_cnt(cnt_l); reverse(A, A + N); make_cnt(cnt_r); reverse(A, A + N); reverse(cnt_r, cnt_r + N); for (int i = N; 1 <= i; i--) { cnt_l[i] = cnt_l[i - 1]; cnt_r[i] = cnt_r[i - 1]; } for (int i = 1; i <= N; i++) { bit_l[i] = Bit(bit_arr[0][i]); bit_r[i] = Bit(bit_arr[1][i]); } for (int i = 1; i <= N; i++) bit_r[i].add(i, 1); int suma[SIZE]; for (int i = 0; i < N; i++) suma[i + 1] = suma[i] + A[i]; for (int len = 2; len <= N; len++) { for (int l = 1; l <= N; l++) { int r = l + len; if (N < r) break; { int rv = min(r, l + cnt_l[l]); int cnt = bit_r[r].sum(l + 1, rv); if (cnt) bit_l[l].add(r, 1); } { int lv = max(l, r - cnt_r[r]); int cnt = bit_l[l].sum(lv, r - 1); if (cnt == (r - 1) - lv + 1) bit_r[r - 1].add(l, 1); } } } cout << (bit_l[1].sum(N, N) == 1 ? "A" : "B") << endl; return 0; }