結果

問題 No.973 余興
ユーザー pekempeypekempey
提出日時 2020-01-17 22:05:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,159 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 172,256 KB
実行使用メモリ 296,856 KB
最終ジャッジ日時 2023-09-08 03:11:06
合計ジャッジ時間 62,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,767 ms
296,560 KB
testcase_01 AC 1,778 ms
296,516 KB
testcase_02 AC 1,756 ms
296,520 KB
testcase_03 AC 1,763 ms
296,368 KB
testcase_04 AC 1,727 ms
296,628 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,665 ms
284,944 KB
testcase_11 AC 521 ms
108,820 KB
testcase_12 AC 508 ms
108,912 KB
testcase_13 WA -
testcase_14 AC 511 ms
108,072 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 20 ms
10,704 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 37 ms
15,192 KB
testcase_23 AC 28 ms
12,920 KB
testcase_24 AC 28 ms
12,920 KB
testcase_25 AC 10 ms
7,600 KB
testcase_26 AC 19 ms
10,612 KB
testcase_27 AC 43 ms
16,740 KB
testcase_28 WA -
testcase_29 AC 26 ms
12,740 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,729 ms
295,244 KB
testcase_35 AC 1,759 ms
296,580 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,732 ms
295,720 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,384 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 1,710 ms
296,684 KB
testcase_47 WA -
testcase_48 AC 1,737 ms
296,628 KB
testcase_49 WA -
testcase_50 AC 1,673 ms
294,500 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,714 ms
291,636 KB
testcase_54 AC 1,734 ms
296,528 KB
testcase_55 AC 1,741 ms
296,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  int N; cin >> N;
  ll X; cin >> X;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  vector<ll> S(N + 1); rep(i, N) S[i + 1] = S[i] + A[i];
  vector<ll> R(N + 1); repr(i, N) R[i] = R[i + 1] + A[i];
  vector<vector<int>> dp(N, vector<int>(N));
  vector<vector<int>> eplr(N, vector<int>(N));
  vector<vector<int>> eprl(N, vector<int>(N));
  for (int d = 1; d <= N - 1; d++) {
    for (int l = 0; l + d <= N - 1; l++) {
      int r = l + d;
      eplr[l][r] = dp[l][l] + eplr[l + 1][r];
      eprl[r][l] = dp[r][r] + eplr[r - 1][l];
      // dpl[l][l+1]...dpl[l][l+x] -> 0
      // dpr[r][r]...dpr[r][r-y] -> 0
      int x = upper_bound(range(S), X + S[l]) - S.begin() - 1;
      int y = upper_bound(S.rbegin(), S.rbegin(), X + S[r + 1]) - S.rend() + 1;
      if (eplr[l][x] != x - l + 1) {
        dp[l][r] = 1;
      }
      if (eprl[r][y] != r - y + 1) {
        dp[l][r] = 1;
      }
    }
  }
  cout << (dp[0][N - 1] ? "A" : "B") << endl;
}
0