結果

問題 No.1148 土偶Ⅲ
ユーザー 👑 KazunKazun
提出日時 2021-02-14 17:41:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 612 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 78,128 KB
最終ジャッジ日時 2023-09-29 09:14:24
合計ジャッジ時間 4,476 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,224 KB
testcase_01 AC 70 ms
71,008 KB
testcase_02 AC 70 ms
71,240 KB
testcase_03 AC 71 ms
71,396 KB
testcase_04 AC 70 ms
71,408 KB
testcase_05 AC 109 ms
77,620 KB
testcase_06 AC 117 ms
78,128 KB
testcase_07 AC 104 ms
77,556 KB
testcase_08 AC 112 ms
77,892 KB
testcase_09 AC 109 ms
77,988 KB
testcase_10 AC 102 ms
77,548 KB
testcase_11 AC 105 ms
77,684 KB
testcase_12 AC 76 ms
76,388 KB
testcase_13 AC 95 ms
76,836 KB
testcase_14 AC 88 ms
76,276 KB
testcase_15 AC 99 ms
77,432 KB
testcase_16 AC 91 ms
76,804 KB
testcase_17 AC 110 ms
77,852 KB
testcase_18 AC 84 ms
76,232 KB
testcase_19 AC 106 ms
77,708 KB
testcase_20 AC 94 ms
77,168 KB
testcase_21 AC 92 ms
77,304 KB
testcase_22 AC 86 ms
76,780 KB
testcase_23 AC 85 ms
76,620 KB
testcase_24 AC 86 ms
76,772 KB
testcase_25 AC 89 ms
76,692 KB
testcase_26 AC 107 ms
77,684 KB
testcase_27 AC 86 ms
76,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline

N,W=map(int,input().split())
A=[0]*N
for i in range(N):
    A[i]=int(input())

Set=set()
Total=0
X=0
R=0
for L in range(N):
    while R<N and (Total+A[R]<=W) and (A[R] not in Set):
        Total+=A[R]
        Set.add(A[R])
        R+=1

    X=max(X,R-L)

    if L==R:
        R+=1
    else:
        Total-=A[L]
        Set.discard(A[L])

print(X)
0