結果

問題 No.1148 土偶Ⅲ
ユーザー H20
提出日時 2022-01-27 23:53:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 92,044 KB
最終ジャッジ日時 2024-12-26 08:26:16
合計ジャッジ時間 4,962 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

N,W = map(int, input().split())
A = []
for _ in range(N):
    A.append(int(input()))
D = collections.defaultdict(int)
ans = 0
j = 0
s = 0
for i in range(N+1):
    while j<N and s<=W and D[A[j]]==0:
        D[A[j]]=1
        s+=A[j]
        ans = max(ans,j-i+1)
        j += 1
    if i==N:
        break
    s -= A[i]
    D[A[i]]=0

if ans<=1:
    print(0)
else:
    print(ans)
0