結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 609 ms
198,956 KB
testcase_01 AC 602 ms
198,892 KB
testcase_02 AC 620 ms
198,616 KB
testcase_03 AC 598 ms
198,744 KB
testcase_04 AC 603 ms
199,204 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 572 ms
191,092 KB
testcase_11 AC 224 ms
73,500 KB
testcase_12 AC 223 ms
73,768 KB
testcase_13 WA -
testcase_14 AC 216 ms
72,960 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 7 ms
8,036 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 14 ms
10,960 KB
testcase_23 AC 9 ms
9,380 KB
testcase_24 AC 8 ms
9,408 KB
testcase_25 AC 5 ms
5,976 KB
testcase_26 AC 7 ms
7,808 KB
testcase_27 AC 17 ms
12,304 KB
testcase_28 WA -
testcase_29 AC 8 ms
9,328 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 803 ms
198,052 KB
testcase_35 AC 812 ms
199,016 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 821 ms
198,088 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 812 ms
199,004 KB
testcase_47 WA -
testcase_48 AC 801 ms
198,912 KB
testcase_49 WA -
testcase_50 AC 787 ms
197,304 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 778 ms
195,552 KB
testcase_54 AC 800 ms
198,892 KB
testcase_55 AC 797 ms
198,632 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] - dp_r[i + chou][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] - dp_l[i][j - chou] != 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