結果

問題 No.973 余興
ユーザー risujirohrisujiroh
提出日時 2020-01-17 22:19:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 669 ms / 4,000 ms
コード長 886 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 171,448 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-06-25 21:07:58
合計ジャッジ時間 17,028 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

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