結果
問題 | No.973 余興 |
ユーザー | kcvlex |
提出日時 | 2020-01-18 02:10:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,146 bytes |
コンパイル時間 | 1,814 ms |
コンパイル使用メモリ | 169,468 KB |
実行使用メモリ | 276,724 KB |
最終ジャッジ日時 | 2024-06-26 05:40:03 |
合計ジャッジ時間 | 57,288 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,097 ms
267,776 KB |
testcase_01 | AC | 2,136 ms
268,672 KB |
testcase_02 | AC | 2,115 ms
265,472 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 2,169 ms
269,440 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2,146 ms
267,904 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 90 ms
40,064 KB |
testcase_17 | AC | 55 ms
32,512 KB |
testcase_18 | WA | - |
testcase_19 | AC | 63 ms
35,584 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 82 ms
39,552 KB |
testcase_23 | WA | - |
testcase_24 | AC | 68 ms
35,968 KB |
testcase_25 | AC | 35 ms
26,112 KB |
testcase_26 | AC | 52 ms
32,256 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 62 ms
35,840 KB |
testcase_30 | WA | - |
testcase_31 | AC | 1,273 ms
205,440 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 1,234 ms
204,672 KB |
testcase_35 | WA | - |
testcase_36 | AC | 1,224 ms
201,856 KB |
testcase_37 | AC | 1,219 ms
202,880 KB |
testcase_38 | WA | - |
testcase_39 | AC | 1,287 ms
205,952 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 | AC | 2 ms
5,376 KB |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | AC | 857 ms
175,872 KB |
testcase_48 | WA | - |
testcase_49 | AC | 815 ms
169,856 KB |
testcase_50 | WA | - |
testcase_51 | AC | 854 ms
176,256 KB |
testcase_52 | WA | - |
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 { ll *data; ll id_ele = 0; Bit() : Bit(nullptr) { } Bit(ll *data) : data(data) { } ll sum(ll pos) { if (pos == 0) return 0; ll ret = id_ele; for(; 0 < pos; pos -= pos & -pos) ret += data[pos]; return ret; } ll sum(ll l, ll r) { return sum(r) - sum(l - 1); } void add(ll pos, ll delta) { for(; pos < SIZE; pos += pos & -pos) data[pos] += delta; } }; ll bit_arr[2][SIZE][SIZE]; Bit bit_l[SIZE], bit_r[SIZE]; ll cnt_l[SIZE], cnt_r[SIZE]; ll A[SIZE]; ll N, X; int main() { cin >> N >> X; for (ll i = 0; i < N; i++) cin >> A[i]; auto make_cnt = [&](ll cnt_v[]) { ll l = 0, r = 0; ll sum = 0; for (ll 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 (ll i = N; 1 <= i; i--) { cnt_l[i] = cnt_l[i - 1]; cnt_r[i] = cnt_r[i - 1]; } for (ll i = 1; i <= N; i++) { bit_l[i] = Bit(bit_arr[0][i]); bit_r[i] = Bit(bit_arr[1][i]); } for (ll i = 1; i <= N; i++) bit_r[i].add(i, 1); ll suma[SIZE] = {}; for (ll i = 1; i <= N; i++) suma[i] = suma[i - 1] + A[i - 1]; for (ll len = 2; len <= N; len++) { for (ll l = 1; l <= N; l++) { ll r = l + len - 1; if (N < r) break; if (suma[r] - suma[l - 1] <= X) { bit_l[l].add(r, 1); continue; } { ll rv = min(r, l + cnt_l[l]); ll cnt = bit_r[r].sum(l + 1, rv); if (cnt) bit_l[l].add(r, 1); } { ll lv = max(r - cnt_r[r], l); ll cnt = bit_l[l].sum(lv, r - 1); if(cnt == (r - 1) - lv + 1) bit_r[r].add(l, 1); } } } /* for (ll i = 1; i <= N; i++) for (ll j = i; j <= N; j++) DEBUG(make_tuple(i, j, bit_l[i].sum(j, j), bit_r[j].sum(i, i))); for (ll i = 1; i <= N; i++) DEBUG(make_tuple(i, cnt_l[i])); */ cout << (bit_l[1].sum(N, N) == 1 ? "A" : "B") << endl; return 0; }