結果

問題 No.974 最後の日までに
ユーザー pekempeypekempey
提出日時 2020-01-17 22:28:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,219 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 172,224 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-08 04:36:45
合計ジャッジ時間 7,161 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
testcase_30 RE -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 RE -
testcase_48 RE -
testcase_49 WA -
testcase_50 RE -
testcase_51 RE -
権限があれば一括ダウンロードができます

ソースコード

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 = upper_bound(range(S), X + S[l]) - S.begin() - 2;
      int y = R.rend() - upper_bound(R.rbegin(), R.rend(), X + R[r + 1]) + 1;
      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