結果

問題 No.1148 土偶Ⅲ
ユーザー 👑 H20H20
提出日時 2022-01-27 23:52:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 612 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 92,552 KB
最終ジャッジ日時 2023-08-27 02:28:54
合計ジャッジ時間 7,156 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,720 KB
testcase_01 AC 94 ms
71,692 KB
testcase_02 AC 93 ms
71,768 KB
testcase_03 AC 94 ms
71,608 KB
testcase_04 AC 93 ms
71,888 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 127 ms
78,084 KB
testcase_24 AC 131 ms
78,452 KB
testcase_25 AC 135 ms
78,780 KB
testcase_26 AC 164 ms
80,836 KB
testcase_27 AC 127 ms
77,740 KB
権限があれば一括ダウンロードができます

ソースコード

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]]-=1

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