結果

問題 No.973 余興
ユーザー pekempeypekempey
提出日時 2020-01-17 22:48:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,555 ms / 4,000 ms
コード長 1,576 bytes
コンパイル時間 1,544 ms
コンパイル使用メモリ 170,600 KB
実行使用メモリ 296,668 KB
最終ジャッジ日時 2023-09-08 05:53:22
合計ジャッジ時間 81,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,155 ms
296,524 KB
testcase_01 AC 2,161 ms
296,604 KB
testcase_02 AC 2,138 ms
296,560 KB
testcase_03 AC 2,141 ms
296,396 KB
testcase_04 AC 2,150 ms
296,572 KB
testcase_05 AC 2,139 ms
296,612 KB
testcase_06 AC 2,171 ms
296,556 KB
testcase_07 AC 2,155 ms
296,256 KB
testcase_08 AC 2,154 ms
295,516 KB
testcase_09 AC 2,153 ms
296,528 KB
testcase_10 AC 2,051 ms
284,940 KB
testcase_11 AC 743 ms
108,968 KB
testcase_12 AC 713 ms
108,860 KB
testcase_13 AC 728 ms
108,092 KB
testcase_14 AC 747 ms
108,164 KB
testcase_15 AC 49 ms
15,280 KB
testcase_16 AC 50 ms
15,476 KB
testcase_17 AC 27 ms
10,732 KB
testcase_18 AC 37 ms
12,968 KB
testcase_19 AC 37 ms
13,020 KB
testcase_20 AC 27 ms
10,656 KB
testcase_21 AC 49 ms
15,288 KB
testcase_22 AC 48 ms
15,172 KB
testcase_23 AC 38 ms
12,952 KB
testcase_24 AC 36 ms
12,876 KB
testcase_25 AC 15 ms
7,644 KB
testcase_26 AC 26 ms
10,516 KB
testcase_27 AC 58 ms
16,724 KB
testcase_28 AC 38 ms
12,940 KB
testcase_29 AC 38 ms
12,836 KB
testcase_30 AC 2,471 ms
296,524 KB
testcase_31 AC 2,479 ms
296,564 KB
testcase_32 AC 2,555 ms
296,668 KB
testcase_33 AC 2,467 ms
296,260 KB
testcase_34 AC 2,447 ms
295,388 KB
testcase_35 AC 2,522 ms
296,656 KB
testcase_36 AC 2,381 ms
288,648 KB
testcase_37 AC 2,390 ms
288,648 KB
testcase_38 AC 2,459 ms
295,804 KB
testcase_39 AC 2,492 ms
296,028 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2,385 ms
296,516 KB
testcase_47 AC 2,395 ms
296,576 KB
testcase_48 AC 2,495 ms
296,664 KB
testcase_49 AC 2,197 ms
273,592 KB
testcase_50 AC 2,416 ms
294,448 KB
testcase_51 AC 2,411 ms
296,620 KB
testcase_52 AC 2,530 ms
296,588 KB
testcase_53 AC 2,485 ms
291,656 KB
testcase_54 AC 2,516 ms
296,568 KB
testcase_55 AC 2,482 ms
296,560 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<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 + 1] <= 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