結果

問題 No.973 余興
ユーザー MayimgMayimg
提出日時 2020-01-20 15:47:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 197,676 KB
実行使用メモリ 199,464 KB
最終ジャッジ日時 2023-09-15 21:03:29
合計ジャッジ時間 6,713 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 47 ms
199,152 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 46 ms
199,140 KB
testcase_06 AC 48 ms
199,304 KB
testcase_07 AC 47 ms
199,104 KB
testcase_08 AC 48 ms
199,176 KB
testcase_09 AC 47 ms
199,116 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 47 ms
199,324 KB
testcase_14 WA -
testcase_15 AC 47 ms
199,092 KB
testcase_16 AC 51 ms
199,252 KB
testcase_17 WA -
testcase_18 AC 51 ms
199,156 KB
testcase_19 AC 47 ms
199,148 KB
testcase_20 AC 46 ms
199,220 KB
testcase_21 AC 47 ms
199,140 KB
testcase_22 AC 46 ms
199,048 KB
testcase_23 AC 46 ms
199,084 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 46 ms
199,336 KB
testcase_29 WA -
testcase_30 AC 48 ms
199,388 KB
testcase_31 AC 48 ms
199,152 KB
testcase_32 AC 47 ms
199,204 KB
testcase_33 AC 47 ms
199,260 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 46 ms
199,140 KB
testcase_37 AC 46 ms
199,136 KB
testcase_38 WA -
testcase_39 AC 47 ms
199,344 KB
testcase_40 AC 46 ms
199,208 KB
testcase_41 AC 46 ms
199,132 KB
testcase_42 AC 46 ms
199,072 KB
testcase_43 AC 47 ms
199,304 KB
testcase_44 WA -
testcase_45 AC 46 ms
199,152 KB
testcase_46 WA -
testcase_47 AC 49 ms
199,200 KB
testcase_48 WA -
testcase_49 AC 49 ms
199,204 KB
testcase_50 WA -
testcase_51 AC 48 ms
199,120 KB
testcase_52 AC 47 ms
199,104 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

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, right, 1)) res = true;
    }
  } else {
    for (int i = right; i >= left; i--) {
      if (sum[right] - sum[i - 1] > x) break;
      if (!rec(left, right, 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