結果

問題 No.1148 土偶Ⅲ
ユーザー first_vil
提出日時 2020-08-06 11:17:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 82,776 KB
実行使用メモリ 89,856 KB
最終ジャッジ日時 2024-09-19 11:10:55
合計ジャッジ時間 4,064 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  n,w=map(int,input().split())
  a=[int(input()) for _ in range(n)]
  d={}
  ans=0
  cur=0
  r=0
  for l in range(n):
    while r<n and (a[r] not in d or not d[a[r]]) and cur+a[r]<=w:
      cur+=a[r]
      d[a[r]]=True
      r+=1
    if ans<r-l:
      ans=r-l
    cur-=a[l]
    d[a[l]]=False
  print(ans)
main()
0