結果

問題 No.1148 土偶Ⅲ
ユーザー yuppe19 😺yuppe19 😺
提出日時 2020-08-05 23:10:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 17,176 KB
最終ジャッジ日時 2023-10-17 23:18:55
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,148 KB
testcase_01 AC 29 ms
10,148 KB
testcase_02 AC 29 ms
10,148 KB
testcase_03 AC 28 ms
10,148 KB
testcase_04 AC 28 ms
10,148 KB
testcase_05 AC 137 ms
12,984 KB
testcase_06 AC 348 ms
17,176 KB
testcase_07 AC 238 ms
16,088 KB
testcase_08 AC 312 ms
16,720 KB
testcase_09 AC 305 ms
16,720 KB
testcase_10 AC 149 ms
13,116 KB
testcase_11 AC 303 ms
16,744 KB
testcase_12 AC 47 ms
10,588 KB
testcase_13 AC 63 ms
11,024 KB
testcase_14 AC 55 ms
10,932 KB
testcase_15 AC 218 ms
15,900 KB
testcase_16 AC 102 ms
11,848 KB
testcase_17 AC 339 ms
17,044 KB
testcase_18 AC 38 ms
10,340 KB
testcase_19 AC 154 ms
13,176 KB
testcase_20 AC 189 ms
13,564 KB
testcase_21 AC 147 ms
13,112 KB
testcase_22 AC 48 ms
10,612 KB
testcase_23 AC 78 ms
10,256 KB
testcase_24 AC 106 ms
10,424 KB
testcase_25 AC 114 ms
10,424 KB
testcase_26 AC 349 ms
10,948 KB
testcase_27 AC 70 ms
10,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# †
from collections import Counter, deque

###
if __name__ == '__main__':
    N, W = map(int, input().split())
    a = [int(input()) for _ in range(N)]
    deq = deque()
    acc = 0
    cnt = Counter()
    maxi = 0
    size = 0
    for ai in a:
        deq.append(ai)
        acc += ai
        cnt[ai] += 1
        size += 1
        while cnt[ai] > 1 or W < acc:
            top = deq.popleft()
            cnt[top] -= 1
            acc -= top
            size -= 1
        maxi = max(maxi, size)
    print(maxi)
0