結果

問題 No.973 余興
ユーザー risujirohrisujiroh
提出日時 2020-01-17 22:19:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 676 ms / 4,000 ms
コード長 886 bytes
コンパイル時間 1,802 ms
コンパイル使用メモリ 169,696 KB
実行使用メモリ 9,396 KB
最終ジャッジ日時 2023-09-08 03:55:28
合計ジャッジ時間 18,402 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
9,192 KB
testcase_01 AC 256 ms
9,392 KB
testcase_02 AC 256 ms
9,396 KB
testcase_03 AC 255 ms
9,316 KB
testcase_04 AC 258 ms
9,204 KB
testcase_05 AC 259 ms
9,308 KB
testcase_06 AC 261 ms
9,212 KB
testcase_07 AC 257 ms
9,232 KB
testcase_08 AC 257 ms
9,316 KB
testcase_09 AC 260 ms
9,312 KB
testcase_10 AC 250 ms
9,040 KB
testcase_11 AC 129 ms
6,688 KB
testcase_12 AC 129 ms
6,688 KB
testcase_13 AC 129 ms
6,752 KB
testcase_14 AC 131 ms
6,656 KB
testcase_15 AC 17 ms
4,376 KB
testcase_16 AC 17 ms
4,376 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 13 ms
4,380 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 16 ms
4,384 KB
testcase_22 AC 16 ms
4,376 KB
testcase_23 AC 14 ms
4,376 KB
testcase_24 AC 14 ms
4,380 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 12 ms
4,376 KB
testcase_27 AC 19 ms
4,376 KB
testcase_28 AC 13 ms
4,380 KB
testcase_29 AC 14 ms
4,376 KB
testcase_30 AC 537 ms
9,192 KB
testcase_31 AC 534 ms
9,376 KB
testcase_32 AC 529 ms
9,312 KB
testcase_33 AC 526 ms
9,308 KB
testcase_34 AC 525 ms
9,252 KB
testcase_35 AC 528 ms
9,276 KB
testcase_36 AC 513 ms
9,260 KB
testcase_37 AC 515 ms
9,384 KB
testcase_38 AC 525 ms
9,324 KB
testcase_39 AC 528 ms
9,252 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 676 ms
9,388 KB
testcase_47 AC 676 ms
9,276 KB
testcase_48 AC 674 ms
9,228 KB
testcase_49 AC 598 ms
9,048 KB
testcase_50 AC 669 ms
9,212 KB
testcase_51 AC 673 ms
9,192 KB
testcase_52 AC 358 ms
9,260 KB
testcase_53 AC 347 ms
9,256 KB
testcase_54 AC 352 ms
9,316 KB
testcase_55 AC 355 ms
9,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<int> mr(n);
  for (int l = 0; l < n; ++l) {
    int r = l, s = 0;
    while (r < n and s + a[r] <= x) {
      s += a[r++];
    }
    mr[l] = r;
  }
  vector<int> ml(n + 1);
  for (int r = n; r; --r) {
    int l = r, s = 0;
    while (l and s + a[l - 1] <= x) {
      s += a[--l];
    }
    ml[r] = l;
  }
  vector<bitset<5001>> lr(n + 1), rl(n + 1);
  for (int r = 1; r <= n; ++r) {
    for (int l = r; l--; ) {
      lr[l][r] = rl[r][l] = 1;
      if ((int)rl[r]._Find_next(l) <= mr[l]) {
        lr[l][r] = rl[r][l] = 0;
      }
      if ((int)lr[l]._Find_next(ml[r] - 1) < r) {
        lr[l][r] = rl[r][l] = 0;
      }
    }
  }
  cout << (char)('A' + lr[0][n]) << '\n';
}
0