結果

問題 No.150 "良問"(良問とは言っていない
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-24 02:32:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 671 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-19 09:30:00
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
12,544 KB
testcase_01 AC 85 ms
12,160 KB
testcase_02 AC 85 ms
12,160 KB
testcase_03 AC 84 ms
12,416 KB
testcase_04 AC 89 ms
12,160 KB
testcase_05 AC 87 ms
12,416 KB
testcase_06 AC 166 ms
12,288 KB
testcase_07 AC 85 ms
12,160 KB
testcase_08 AC 89 ms
12,160 KB
testcase_09 AC 87 ms
12,288 KB
testcase_10 AC 110 ms
12,416 KB
testcase_11 AC 113 ms
12,544 KB
testcase_12 AC 105 ms
12,416 KB
testcase_13 AC 115 ms
12,416 KB
testcase_14 AC 124 ms
12,544 KB
testcase_15 AC 116 ms
12,416 KB
testcase_16 AC 92 ms
12,288 KB
testcase_17 AC 99 ms
12,288 KB
testcase_18 AC 119 ms
12,288 KB
testcase_19 AC 125 ms
12,544 KB
testcase_20 AC 130 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

t = gets.to_i
good = "good"
prob = "problem"
glen = good.length
plen = prob.length
t.times do
    str = gets.strip
    n = str.length - plen - glen + 1
    a = Array.new
    b = Array.new
    n.times do |i|
        ac = 0
        bc = 0
        glen.times do |j|
            ac += 1 if str[i + j] == good[j]
        end
        plen.times do |j|
            bc += 1 if str[i + j + glen] == prob[j]
        end
        a.push(ac)
        b.push(bc)
    end
    max = 0
    a.length.times do |i|
        i.upto(b.length - 1) do |j|
            k = a[i] + b[j]
            if k > max
                max = k
            end
        end
    end
    puts plen + glen - max
end
0