結果

問題 No.973 余興
ユーザー pekempeypekempey
提出日時 2020-01-17 22:41:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,630 bytes
コンパイル時間 1,601 ms
コンパイル使用メモリ 171,912 KB
実行使用メモリ 296,888 KB
最終ジャッジ日時 2023-09-08 05:23:05
合計ジャッジ時間 75,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,939 ms
296,596 KB
testcase_02 AC 1,904 ms
296,556 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1,936 ms
296,584 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 709 ms
108,252 KB
testcase_14 AC 684 ms
108,128 KB
testcase_15 AC 47 ms
15,356 KB
testcase_16 AC 48 ms
15,536 KB
testcase_17 AC 25 ms
10,736 KB
testcase_18 WA -
testcase_19 AC 37 ms
13,056 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 47 ms
15,328 KB
testcase_23 AC 36 ms
13,004 KB
testcase_24 AC 36 ms
12,976 KB
testcase_25 AC 14 ms
7,764 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 36 ms
12,720 KB
testcase_30 AC 2,338 ms
296,692 KB
testcase_31 AC 2,284 ms
296,580 KB
testcase_32 AC 2,294 ms
296,712 KB
testcase_33 AC 2,292 ms
296,616 KB
testcase_34 AC 2,303 ms
295,344 KB
testcase_35 AC 2,255 ms
296,888 KB
testcase_36 AC 2,217 ms
289,024 KB
testcase_37 AC 2,204 ms
288,936 KB
testcase_38 AC 2,251 ms
295,920 KB
testcase_39 AC 2,220 ms
296,116 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2,245 ms
296,576 KB
testcase_47 AC 2,133 ms
296,624 KB
testcase_48 AC 2,247 ms
296,596 KB
testcase_49 WA -
testcase_50 AC 2,291 ms
294,432 KB
testcase_51 AC 2,163 ms
296,544 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2,309 ms
296,580 KB
testcase_55 AC 2,259 ms
296,580 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;
      // dpl[l][r]...dpl[x][r] -> 0
      // dpr[l][y]...dpr[l][r] -> 0
      int x, y;
      {
        int lo = l + 1;
        int hi = r + 1;
        while (hi - lo > 1) {
          int mid = (lo + hi) / 2;
          if (S[mid] - S[l] <= X) {
            lo = mid;
          } else {
            hi = mid;
          }
        }
        x = lo;
      }
      {
        int lo = l - 1;
        int hi = r - 1;
        while (hi - lo > 1) {
          int mid = (lo + hi) / 2;
          if (S[r + 1] - S[mid] <= X) {
            hi = mid;
          } else {
            lo = mid;
          }
        }
        y = hi;
      }
      if (eprl[r][l + 1] - eprl[r][x] + dp[x][r] != x - (l + 1) + 1) {
        dp[l][r] = 1;
      }
      if (eplr[l][r - 1] - eplr[l][y] + dp[l][y] != (r - 1) - y + 1) {
        dp[l][r] = 1;
      }
      eplr[l][r] = dp[l][r] + eplr[l][r - 1];
      eprl[r][l] = dp[l][r] + eprl[r][l + 1];
    }
  }
  cout << (dp[0][N - 1] ? "A" : "B") << endl;
}
0