結果

問題 No.1148 土偶Ⅲ
ユーザー 👑 H20H20
提出日時 2022-01-27 23:53:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 92,840 KB
最終ジャッジ日時 2023-08-27 02:31:01
合計ジャッジ時間 5,448 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,920 KB
testcase_01 AC 84 ms
71,536 KB
testcase_02 AC 86 ms
71,572 KB
testcase_03 AC 89 ms
71,692 KB
testcase_04 AC 84 ms
71,728 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 118 ms
77,968 KB
testcase_24 AC 124 ms
78,788 KB
testcase_25 AC 122 ms
78,772 KB
testcase_26 AC 151 ms
81,276 KB
testcase_27 AC 114 ms
78,012 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]]=0

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