結果

問題 No.150 "良問"(良問とは言っていない
ユーザー rlangevinrlangevin
提出日時 2023-01-20 23:55:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 5,000 ms
コード長 487 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 86,368 KB
実行使用メモリ 77,332 KB
最終ジャッジ日時 2023-09-05 16:23:03
合計ジャッジ時間 4,442 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
76,740 KB
testcase_01 AC 73 ms
70,908 KB
testcase_02 AC 79 ms
74,728 KB
testcase_03 AC 78 ms
75,480 KB
testcase_04 AC 77 ms
74,976 KB
testcase_05 AC 85 ms
75,784 KB
testcase_06 AC 179 ms
76,892 KB
testcase_07 AC 77 ms
74,852 KB
testcase_08 AC 86 ms
75,808 KB
testcase_09 AC 82 ms
75,580 KB
testcase_10 AC 120 ms
77,140 KB
testcase_11 AC 128 ms
76,864 KB
testcase_12 AC 111 ms
76,996 KB
testcase_13 AC 125 ms
76,900 KB
testcase_14 AC 132 ms
77,036 KB
testcase_15 AC 128 ms
77,332 KB
testcase_16 AC 87 ms
75,520 KB
testcase_17 AC 106 ms
76,832 KB
testcase_18 AC 131 ms
77,240 KB
testcase_19 AC 139 ms
76,944 KB
testcase_20 AC 138 ms
76,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(S, T):
    if len(S) < len(T):
        return 100
    cnt = 100
    for i in range(len(S) - len(T) + 1):
        v = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                v += 1
        cnt = min(cnt, v)
    return cnt
        

T = int(input())
good = list("good")
problem = list("problem")
for _ in range(T):
    S = list(input())
    ans = 100
    for i in range(len(S)):
        ans = min(ans, f(S[:i], good) + f(S[i:], problem))
    print(ans)    
0