結果

問題 No.1148 土偶Ⅲ
ユーザー 37zigen
提出日時 2020-08-07 20:27:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 292 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,020 KB
最終ジャッジ日時 2024-09-24 17:48:49
合計ジャッジ時間 5,996 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n,w=map(int,input().split())
a=[int(input()) for _ in range(n)]
cnt={}
for v in a:
    cnt[v]=0
t=0
ans=0
sum=0
for s in range(n):
    while t<n and sum+a[t]<=w and cnt[a[t]]==0:
        sum+=a[t]
        cnt[a[t]]=1
        t+=1
    ans=max(ans,t-s)
    sum-=a[s]
    cnt[a[s]]-=1
print(ans)
0