結果

問題 No.973 余興
ユーザー 👑 emthrmemthrm
提出日時 2020-01-18 05:59:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,278 bytes
コンパイル時間 2,201 ms
コンパイル使用メモリ 203,668 KB
実行使用メモリ 199,180 KB
最終ジャッジ日時 2023-09-08 18:09:03
合計ジャッジ時間 33,935 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 795 ms
198,992 KB
testcase_01 AC 794 ms
199,124 KB
testcase_02 WA -
testcase_03 AC 806 ms
198,608 KB
testcase_04 AC 795 ms
198,896 KB
testcase_05 AC 799 ms
198,872 KB
testcase_06 AC 797 ms
198,624 KB
testcase_07 WA -
testcase_08 AC 781 ms
197,820 KB
testcase_09 WA -
testcase_10 AC 758 ms
190,984 KB
testcase_11 AC 255 ms
73,532 KB
testcase_12 AC 253 ms
73,568 KB
testcase_13 AC 252 ms
72,948 KB
testcase_14 AC 250 ms
73,052 KB
testcase_15 WA -
testcase_16 AC 19 ms
11,284 KB
testcase_17 AC 10 ms
8,044 KB
testcase_18 AC 13 ms
9,604 KB
testcase_19 AC 13 ms
9,324 KB
testcase_20 WA -
testcase_21 AC 19 ms
10,908 KB
testcase_22 AC 19 ms
10,964 KB
testcase_23 AC 14 ms
9,336 KB
testcase_24 WA -
testcase_25 AC 7 ms
6,028 KB
testcase_26 AC 10 ms
7,856 KB
testcase_27 WA -
testcase_28 AC 13 ms
9,324 KB
testcase_29 AC 13 ms
9,336 KB
testcase_30 AC 934 ms
198,908 KB
testcase_31 AC 943 ms
198,924 KB
testcase_32 AC 947 ms
198,980 KB
testcase_33 AC 953 ms
198,736 KB
testcase_34 AC 937 ms
198,060 KB
testcase_35 AC 948 ms
198,920 KB
testcase_36 AC 896 ms
193,612 KB
testcase_37 AC 898 ms
193,632 KB
testcase_38 AC 930 ms
198,156 KB
testcase_39 AC 912 ms
198,344 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 951 ms
199,028 KB
testcase_47 AC 938 ms
198,988 KB
testcase_48 AC 948 ms
198,964 KB
testcase_49 AC 816 ms
183,564 KB
testcase_50 AC 910 ms
197,388 KB
testcase_51 AC 907 ms
198,972 KB
testcase_52 AC 934 ms
199,180 KB
testcase_53 AC 908 ms
195,536 KB
testcase_54 AC 937 ms
198,876 KB
testcase_55 AC 922 ms
198,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, x; cin >> n >> x;
  if (n == 1) {
    cout << "B\n";
    return 0;
  }
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<int> l(n, 0), r(n, 0);
  REP(i, n) {
    int sum = a[i], j = i + 1;
    while (j < n && sum + a[j] <= x) ++j;
    l[i] = j - i;
  }
  REP(i, n) {
    int sum = a[i], j = i - 1;
    while (j >= 0 && sum + a[j] <= x) --j;
    r[i] = i - j;
  }
  vector<vector<int> > dp_l(n, vector<int>(n, 0)), dp_r(n, vector<int>(n, 0));
  FOR(len, 2, n + 1) {
    REP(i, n) {
      int j = i + len - 1;
      if (j >= n) break;
      int chou = min(len - 1, l[i]);
      if (dp_r[i + 1][j] - (i + chou + 1 >= n ? 0 : dp_r[i + chou + 1][j]) != chou) {
        dp_l[i][j] = dp_l[i][j - 1] + 1;
        dp_r[i][j] = dp_r[i + 1][j] + 1;
        continue;
      }
      chou = min(len - 1, r[j]);
      if (dp_l[i][j - 1] - (j - chou - 1 < 0 ? 0 : dp_l[i][j - chou - 1]) != chou) {
        dp_l[i][j] = dp_l[i][j - 1] + 1;
        dp_r[i][j] = dp_r[i + 1][j] + 1;
        continue;
      }
      dp_l[i][j] = dp_l[i][j - 1];
      dp_r[i][j] = dp_r[i + 1][j];
    }
  }
  // REP(i, n) REP(j, n) cout << i << ' ' << j << " : " << dp_l[i][j] << '\n';
  cout << (dp_l[0][n - 1] - dp_l[0][n - 2] == 1 ? "A\n" : "B\n");
  return 0;
}
0