結果

問題 No.973 余興
ユーザー maspy
提出日時 2020-05-07 16:06:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 679 ms / 4,000 ms
コード長 551 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,588 KB
最終ジャッジ日時 2024-07-03 09:27:13
合計ジャッジ時間 33,161 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,X = map(int, readline().split())
A = np.array(read().split(), np.int64)

# 長さ n の区間。左、右からとっていったときに、先手負けになるまでに食べる量
dpl = np.zeros_like(A)
dpr = np.zeros_like(A)
for n in range(2, N+1):
    dpl = dpl[1:] + A[:N-n+1]
    dpr = dpr[:-1] + A[n-1:]
    lose = (dpl > X) & (dpr > X)
    dpl[lose] = 0
    dpr[lose] = 0

print('A' if dpl[0] else 'B')
0