結果

問題 No.1148 土偶Ⅲ
ユーザー first_vilfirst_vil
提出日時 2020-08-06 11:17:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 1,472 ms
コンパイル使用メモリ 81,328 KB
実行使用メモリ 89,428 KB
最終ジャッジ日時 2023-10-19 15:02:43
合計ジャッジ時間 5,674 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,596 KB
testcase_01 AC 38 ms
51,572 KB
testcase_02 AC 38 ms
51,644 KB
testcase_03 AC 38 ms
51,580 KB
testcase_04 AC 39 ms
51,600 KB
testcase_05 AC 102 ms
79,540 KB
testcase_06 AC 126 ms
89,428 KB
testcase_07 AC 104 ms
83,292 KB
testcase_08 AC 125 ms
87,968 KB
testcase_09 AC 117 ms
86,632 KB
testcase_10 AC 91 ms
79,552 KB
testcase_11 AC 117 ms
86,644 KB
testcase_12 AC 67 ms
69,496 KB
testcase_13 AC 80 ms
76,164 KB
testcase_14 AC 70 ms
71,480 KB
testcase_15 AC 106 ms
81,260 KB
testcase_16 AC 81 ms
77,588 KB
testcase_17 AC 122 ms
87,960 KB
testcase_18 AC 66 ms
68,572 KB
testcase_19 AC 92 ms
80,112 KB
testcase_20 AC 100 ms
81,552 KB
testcase_21 AC 91 ms
79,544 KB
testcase_22 AC 68 ms
70,424 KB
testcase_23 AC 71 ms
73,984 KB
testcase_24 AC 78 ms
75,896 KB
testcase_25 AC 79 ms
75,940 KB
testcase_26 AC 112 ms
76,520 KB
testcase_27 AC 69 ms
72,716 KB
権限があれば一括ダウンロードができます

ソースコード

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