結果

問題 No.973 余興
ユーザー chinchilla
提出日時 2020-01-31 02:13:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,473 ms / 4,000 ms
コード長 367 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-09-16 06:26:10
合計ジャッジ時間 22,667 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = map(int, input().split())
a = list(map(int, input().split())) + [x+1]
f, b = [0] * (n+1), [0] * (n+1)
i, j, s = -1, -1, 0
while i < n:
	if s > x:
		f[i] = j
		i += 1
		s -= a[i]
	else:
		j += 1
		s += a[j]
		b[j] = i
f[n-1] = 0
for j in range(n):
	i = b[j]
	while i >= 0:
		if f[i] <= j:
			f[i] = f[j]
			i = b[i]
		else:
			i -= 1
print("A" if f[0] else "B")
0