結果

問題 No.345 最小チワワ問題
ユーザー ohanaohana
提出日時 2023-10-23 17:35:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 61,836 KB
最終ジャッジ日時 2023-10-23 17:35:31
合計ジャッジ時間 3,613 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,560 KB
testcase_01 AC 42 ms
53,560 KB
testcase_02 AC 40 ms
53,560 KB
testcase_03 AC 40 ms
53,560 KB
testcase_04 AC 42 ms
53,560 KB
testcase_05 AC 41 ms
53,560 KB
testcase_06 AC 42 ms
53,560 KB
testcase_07 AC 43 ms
53,560 KB
testcase_08 AC 42 ms
53,560 KB
testcase_09 AC 43 ms
53,560 KB
testcase_10 AC 43 ms
53,560 KB
testcase_11 AC 41 ms
53,560 KB
testcase_12 AC 45 ms
59,788 KB
testcase_13 AC 41 ms
55,608 KB
testcase_14 AC 45 ms
61,836 KB
testcase_15 AC 42 ms
53,560 KB
testcase_16 AC 42 ms
53,560 KB
testcase_17 AC 41 ms
53,560 KB
testcase_18 AC 41 ms
55,608 KB
testcase_19 AC 40 ms
53,560 KB
testcase_20 AC 41 ms
53,560 KB
testcase_21 AC 41 ms
53,560 KB
testcase_22 AC 42 ms
53,560 KB
testcase_23 AC 41 ms
53,560 KB
testcase_24 AC 42 ms
53,560 KB
testcase_25 AC 40 ms
53,560 KB
testcase_26 AC 41 ms
53,560 KB
testcase_27 AC 41 ms
53,560 KB
testcase_28 AC 42 ms
53,560 KB
testcase_29 AC 42 ms
53,560 KB
testcase_30 AC 41 ms
53,560 KB
testcase_31 AC 41 ms
53,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

s = input()
dq = deque()
cww = deque()
mn = float("inf")
for c in s:
    for i in range(len(dq)):
        dq[i] += 1
    if c == "c":
        dq.append(1)
        cww.append(0)
    if c == "w":
        for i in range(len(dq)):
            cww[i] += 1
        while cww and cww[0] == 2:
            cww.popleft()
            mn = min(mn, dq.popleft())
print(mn if mn != float("inf") else -1)
0