結果

問題 No.1148 土偶Ⅲ
ユーザー titia
提出日時 2023-10-24 05:47:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 271 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-09-22 22:37:32
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 6 RE * 19
権限があれば一括ダウンロードができます

ソースコード

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):
    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))
    Q.remove(A[i])
    S-=A[i]

print(ANS)
0