結果

問題 No.1148 土偶Ⅲ
ユーザー square1001square1001
提出日時 2020-08-05 20:30:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 321 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 17,140 KB
最終ジャッジ日時 2023-10-17 12:55:33
合計ジャッジ時間 4,646 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,096 KB
testcase_01 AC 30 ms
10,096 KB
testcase_02 AC 29 ms
10,096 KB
testcase_03 AC 29 ms
10,096 KB
testcase_04 AC 30 ms
10,096 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 82 ms
10,204 KB
testcase_24 AC 110 ms
10,372 KB
testcase_25 AC 118 ms
10,372 KB
testcase_26 AC 368 ms
10,896 KB
testcase_27 AC 73 ms
10,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = map(int, input().split())
A = [ int(input()) for i in range(N) ]
cnts = {}
for i in range(N):
	cnts[A[i]] = 0
R = 0
S = 0
ans = 0
for i in range(N):
	while R < N and S + A[R] <= W and cnts[A[R]] == 0:
		cnts[A[R]] += 1
		S += A[R]
		R += 1
	ans = max(ans, R - i)
	if R > i:
		cnts[A[i]] -= 1
		S -= A[i]
print(ans)
0