結果
問題 |
No.973 余興
|
ユーザー |
![]() |
提出日時 | 2020-01-19 16:18:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 866 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 327,040 KB |
最終ジャッジ日時 | 2024-07-02 21:48:00 |
合計ジャッジ時間 | 10,682 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | TLE * 1 -- * 53 |
ソースコード
import sys sys.setrecursionlimit(10**5) n, x = map(int, input().split()) a = list(map(int, input().split())) ruiseki = [0] * (n + 1) for i in range(n): ruiseki[i + 1] = ruiseki[i] + a[i] def solve(l, r): # [l, r)のシュークリームが残っているときの先手の勝ち負け if r - l == 0: dp[l][r] = True return True if r - l == 1: dp[l][r] = False return False if dp[l][r] is not None: return dp[l][r] tmp = False for newl in range(l + 1, r + 1): if ruiseki[newl] - ruiseki[l] <= x: tmp |= not solve(newl, r) for newr in range(l, r): if ruiseki[r] - ruiseki[newr] <= x: tmp |= not solve(l, newr) dp[l][r] = tmp return tmp dp = [[None] * (n + 1) for i in range(n + 1)] if solve(0, n): print("A") else: print("B")