結果
問題 | No.973 余興 |
ユーザー | kimiyuki |
提出日時 | 2020-01-18 06:50:11 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,416 ms / 4,000 ms |
コード長 | 2,140 bytes |
コンパイル時間 | 2,207 ms |
コンパイル使用メモリ | 210,040 KB |
実行使用メモリ | 101,632 KB |
最終ジャッジ日時 | 2024-06-26 21:04:01 |
合計ジャッジ時間 | 46,537 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,200 ms
101,376 KB |
testcase_01 | AC | 1,185 ms
101,376 KB |
testcase_02 | AC | 1,176 ms
101,376 KB |
testcase_03 | AC | 1,218 ms
101,376 KB |
testcase_04 | AC | 1,173 ms
101,376 KB |
testcase_05 | AC | 1,183 ms
101,376 KB |
testcase_06 | AC | 1,183 ms
101,376 KB |
testcase_07 | AC | 1,172 ms
101,376 KB |
testcase_08 | AC | 1,151 ms
101,120 KB |
testcase_09 | AC | 1,176 ms
101,376 KB |
testcase_10 | AC | 1,114 ms
97,536 KB |
testcase_11 | AC | 366 ms
38,656 KB |
testcase_12 | AC | 363 ms
38,784 KB |
testcase_13 | AC | 355 ms
38,400 KB |
testcase_14 | AC | 355 ms
38,400 KB |
testcase_15 | AC | 30 ms
7,168 KB |
testcase_16 | AC | 31 ms
7,296 KB |
testcase_17 | AC | 19 ms
5,888 KB |
testcase_18 | AC | 24 ms
6,656 KB |
testcase_19 | AC | 24 ms
6,656 KB |
testcase_20 | AC | 19 ms
5,632 KB |
testcase_21 | AC | 31 ms
7,168 KB |
testcase_22 | AC | 31 ms
7,168 KB |
testcase_23 | AC | 25 ms
6,656 KB |
testcase_24 | AC | 25 ms
6,400 KB |
testcase_25 | AC | 12 ms
5,376 KB |
testcase_26 | AC | 18 ms
5,632 KB |
testcase_27 | AC | 35 ms
7,936 KB |
testcase_28 | AC | 25 ms
6,656 KB |
testcase_29 | AC | 24 ms
6,400 KB |
testcase_30 | AC | 1,356 ms
101,376 KB |
testcase_31 | AC | 1,347 ms
101,632 KB |
testcase_32 | AC | 1,357 ms
101,504 KB |
testcase_33 | AC | 1,369 ms
101,504 KB |
testcase_34 | AC | 1,342 ms
100,992 KB |
testcase_35 | AC | 1,327 ms
101,504 KB |
testcase_36 | AC | 1,313 ms
98,944 KB |
testcase_37 | AC | 1,302 ms
98,816 KB |
testcase_38 | AC | 1,383 ms
101,120 KB |
testcase_39 | AC | 1,350 ms
101,248 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 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 1,348 ms
101,504 KB |
testcase_47 | AC | 1,308 ms
101,376 KB |
testcase_48 | AC | 1,316 ms
101,376 KB |
testcase_49 | AC | 1,172 ms
93,696 KB |
testcase_50 | AC | 1,416 ms
100,736 KB |
testcase_51 | AC | 1,307 ms
101,504 KB |
testcase_52 | AC | 1,350 ms
101,376 KB |
testcase_53 | AC | 1,283 ms
99,712 KB |
testcase_54 | AC | 1,391 ms
101,376 KB |
testcase_55 | AC | 1,332 ms
101,248 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i)) #define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i)) #define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i)) #define ALL(x) std::begin(x), std::end(x) using namespace std; template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); } template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); } template <typename T> istream & operator >> (istream & in, vector<T> & xs) { REP (i, xs.size()) { in >> xs[i]; } return in; } /** * @brief a binary search / 二分探索 * @param[in] p a monotone predicate defined on $[l, r)$ * @return $\min \lbrace x \in [l, r) \mid p(x) \rbrace$, or r if it doesn't exist */ template <typename UnaryPredicate> int64_t binsearch(int64_t l, int64_t r, UnaryPredicate p) { assert (l <= r); -- l; while (r - l > 1) { int64_t m = l + (r - l) / 2; (p(m) ? r : l) = m; } return r; } bool solve(int n, int x, const vector<int64_t> & a) { vector<int64_t> acc(n + 1); partial_sum(ALL(a), acc.begin() + 1); auto hr = make_table(n + 1, n + 2, int16_t()); auto vr = make_table(n + 1, n + 2, int16_t()); REP (len, n + 1) REP (l, n - len + 1) { int r = l + len; bool cur; if (len == 0) { cur = true; } else { int m1 = binsearch(l + 1, r, [&](int m1) { return acc[m1] - acc[l] > x; }); int m2 = binsearch(l, r, [&](int m2) { return acc[r] - acc[m2] <= x; }); cur = vr[r][l + 1] - vr[r][m1] + hr[l][r] - hr[l][m2]; } hr[l][r + 1] = hr[l][r] + not cur; vr[r][l] = vr[r][l + 1] + not cur; } return not (hr[0][n + 1] - hr[0][n]); } int main() { int n, x; cin >> n >> x; vector<int64_t> a(n); cin >> a; cout << (solve(n, x, a) ? "A" : "B") << endl; return 0; }