結果

問題 No.973 余興
ユーザー MayimgMayimg
提出日時 2020-01-20 15:48:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 948 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 197,792 KB
実行使用メモリ 203,588 KB
最終ジャッジ日時 2023-09-15 21:06:17
合計ジャッジ時間 10,573 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int memo[5005][5005][2];
long long a[5005], sum[5005];
int n, x;
bool rec (int left, int right, int turn) {
  if (left > right) return true;
  if (left == right) return false;
  if (memo[left][right][turn] != -1) return memo[left][right][turn];
  int& res = memo[left][right][turn];
  res = false;
  if (turn == 0) {
    for (int i = left; i <= right; i++) {
      if (sum[i] - sum[left - 1] > x) break;
      if (!rec(i + 1, right, 1)) res = true;
    }
  } else {
    for (int i = right; i >= left; i--) {
      if (sum[right] - sum[i - 1] > x) break;
      if (!rec(left, i - 1, 0)) res = true;
    }
  }
  return res;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  memset(memo, -1, sizeof(memo));
  cout << (rec(1, n, 0) ? "A\n" : "B\n");
  return 0;
}
0