結果

問題 No.150 "良問"(良問とは言っていない
ユーザー lloyzlloyz
提出日時 2023-06-18 15:57:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 5,000 ms
コード長 567 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 77,736 KB
最終ジャッジ日時 2023-09-08 11:59:25
合計ジャッジ時間 4,509 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
76,452 KB
testcase_01 AC 72 ms
71,192 KB
testcase_02 AC 73 ms
70,964 KB
testcase_03 AC 72 ms
70,956 KB
testcase_04 AC 70 ms
71,204 KB
testcase_05 AC 72 ms
75,004 KB
testcase_06 AC 106 ms
77,484 KB
testcase_07 AC 71 ms
71,064 KB
testcase_08 AC 75 ms
74,996 KB
testcase_09 AC 72 ms
70,964 KB
testcase_10 AC 93 ms
76,412 KB
testcase_11 AC 95 ms
76,608 KB
testcase_12 AC 89 ms
76,808 KB
testcase_13 AC 95 ms
76,748 KB
testcase_14 AC 92 ms
76,460 KB
testcase_15 AC 93 ms
76,568 KB
testcase_16 AC 81 ms
76,564 KB
testcase_17 AC 89 ms
76,588 KB
testcase_18 AC 106 ms
77,736 KB
testcase_19 AC 98 ms
76,848 KB
testcase_20 AC 94 ms
76,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    s = input()
    n = len(s)
    GOOD = [0 for _ in range(n)]
    good = "good"
    PROBLEM = [0 for _ in range(n)]
    problem = "problem"
    for i in range(3, n):
        cnt = 0
        for j in range(4):
            cnt += (s[i - (3 - j)] != good[j])
        GOOD[i] = cnt
    for i in range(n - 6):
        cnt = 0
        for j in range(7):
            cnt += (s[i + j] != problem[j])
        PROBLEM[i] = cnt
    ans = 11
    for i in range(3, n - 7):
        ans = min(ans, GOOD[i] + min(PROBLEM[i + 1:n - 6]))
    print(ans)
0