結果

問題 No.1148 土偶Ⅲ
ユーザー rlangevinrlangevin
提出日時 2023-02-04 14:18:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 87,508 KB
最終ジャッジ日時 2023-09-16 11:06:45
合計ジャッジ時間 6,484 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,580 KB
testcase_01 AC 91 ms
71,268 KB
testcase_02 AC 93 ms
71,672 KB
testcase_03 AC 92 ms
71,380 KB
testcase_04 AC 92 ms
71,384 KB
testcase_05 AC 151 ms
80,776 KB
testcase_06 AC 191 ms
87,508 KB
testcase_07 AC 173 ms
85,904 KB
testcase_08 AC 199 ms
85,692 KB
testcase_09 AC 203 ms
86,392 KB
testcase_10 AC 162 ms
80,864 KB
testcase_11 AC 197 ms
85,540 KB
testcase_12 AC 133 ms
78,472 KB
testcase_13 AC 132 ms
78,144 KB
testcase_14 AC 129 ms
77,912 KB
testcase_15 AC 172 ms
84,740 KB
testcase_16 AC 142 ms
79,656 KB
testcase_17 AC 197 ms
86,256 KB
testcase_18 AC 136 ms
77,852 KB
testcase_19 AC 150 ms
81,344 KB
testcase_20 AC 165 ms
83,524 KB
testcase_21 AC 157 ms
81,356 KB
testcase_22 AC 131 ms
77,720 KB
testcase_23 AC 125 ms
77,968 KB
testcase_24 AC 130 ms
78,340 KB
testcase_25 AC 136 ms
78,148 KB
testcase_26 AC 165 ms
78,352 KB
testcase_27 AC 147 ms
78,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N, W = map(int, input().split())
Q = deque()
D = defaultdict(int)
ans = 0
S = 0
for i in range(N):
    A = int(input())
    D[A] += 1
    S += A
    Q.append(A)
    while D[A] == 2 or S > W:
        B = Q.popleft()
        D[B] -= 1
        S -= B
    ans = max(ans, len(Q))
print(ans)
0