結果

問題 No.1148 土偶Ⅲ
ユーザー titiatitia
提出日時 2023-10-24 05:50:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 13,516 KB
最終ジャッジ日時 2023-10-24 05:50:06
合計ジャッジ時間 4,965 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,172 KB
testcase_01 AC 28 ms
10,172 KB
testcase_02 AC 29 ms
10,172 KB
testcase_03 AC 28 ms
10,172 KB
testcase_04 AC 28 ms
10,172 KB
testcase_05 AC 136 ms
11,372 KB
testcase_06 AC 311 ms
13,516 KB
testcase_07 AC 206 ms
12,452 KB
testcase_08 AC 275 ms
13,128 KB
testcase_09 AC 271 ms
13,064 KB
testcase_10 AC 144 ms
11,488 KB
testcase_11 AC 245 ms
12,976 KB
testcase_12 AC 42 ms
10,368 KB
testcase_13 AC 61 ms
10,544 KB
testcase_14 AC 52 ms
10,452 KB
testcase_15 AC 189 ms
12,212 KB
testcase_16 AC 91 ms
10,896 KB
testcase_17 AC 326 ms
13,388 KB
testcase_18 AC 36 ms
10,284 KB
testcase_19 AC 152 ms
11,488 KB
testcase_20 AC 154 ms
11,752 KB
testcase_21 AC 123 ms
11,500 KB
testcase_22 AC 45 ms
10,388 KB
testcase_23 AC 81 ms
10,280 KB
testcase_24 AC 112 ms
10,448 KB
testcase_25 AC 120 ms
10,452 KB
testcase_26 AC 378 ms
10,972 KB
testcase_27 AC 71 ms
10,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,w=map(int,input().split())
A=[int(input()) for i in range(n)]

Q=set()
S=0

r=0
ANS=0
for i in range(n):
    r=max(r,i)
    while r<n and not(A[r] in Q) and S+A[r]<=w:
        Q.add(A[r])
        S+=A[r]
        r+=1

    ANS=max(ANS,len(Q))

    if r>i:
        Q.remove(A[i])
        S-=A[i]

print(ANS)
0