結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,048 KB
testcase_01 AC 28 ms
10,048 KB
testcase_02 AC 29 ms
10,048 KB
testcase_03 AC 29 ms
10,048 KB
testcase_04 AC 29 ms
10,048 KB
testcase_05 AC 133 ms
12,884 KB
testcase_06 AC 313 ms
17,076 KB
testcase_07 AC 199 ms
15,988 KB
testcase_08 AC 270 ms
16,620 KB
testcase_09 AC 266 ms
16,620 KB
testcase_10 AC 143 ms
13,016 KB
testcase_11 AC 241 ms
16,644 KB
testcase_12 AC 41 ms
10,488 KB
testcase_13 AC 62 ms
10,924 KB
testcase_14 AC 52 ms
10,832 KB
testcase_15 AC 176 ms
15,796 KB
testcase_16 AC 88 ms
11,744 KB
testcase_17 AC 324 ms
16,944 KB
testcase_18 AC 37 ms
10,240 KB
testcase_19 AC 149 ms
13,076 KB
testcase_20 AC 151 ms
13,464 KB
testcase_21 AC 119 ms
13,012 KB
testcase_22 AC 44 ms
10,488 KB
testcase_23 AC 81 ms
10,160 KB
testcase_24 AC 110 ms
10,324 KB
testcase_25 AC 118 ms
10,324 KB
testcase_26 AC 364 ms
10,848 KB
testcase_27 AC 72 ms
10,160 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]
	else:
		R = i + 1
print(ans)
0