結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー maspymaspy
提出日時 2020-03-07 00:18:18
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 828 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 251,204 KB
最終ジャッジ日時 2024-04-22 11:03:37
合計ジャッジ時間 8,787 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,086 ms
83,584 KB
testcase_01 AC 1,077 ms
85,664 KB
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 AC 56 ms
64,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools


# %%
T = int(readline())
words = read().decode().split()


# %%
def solve(S):
    INF = 10 ** 7
    L = len(S)
    problem = [i + 7 for i in range(L - 6) if S[i: i + 7] == 'problem']
    G = [sum(x != y for x, y in zip(S[i: i + 4], 'good')) for i in range(L)]
    add = [0] * L
    for i in problem:
        if i < L:
            add[i] += 1
    for n in range(L - 1):
        add[n + 1] += add[n]
    G = [x + y for x, y in zip(G, add)]
    G = list(itertools.accumulate([INF] * 4 + G[:-4], min))
    for i in range(L - 6):
        G[i] += sum(x != y for x, y in zip(S[i: i + 7], 'problem'))
    return min(G[: L - 6])


for w in words:
    print(solve(w))


# %%
0