結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー | siman |
提出日時 | 2016-03-23 18:27:38 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 343 ms / 5,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 177 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 13,444 KB |
最終ジャッジ日時 | 2024-04-19 09:32:14 |
合計ジャッジ時間 | 4,070 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 161 ms
12,672 KB |
testcase_01 | AC | 85 ms
12,416 KB |
testcase_02 | AC | 86 ms
12,160 KB |
testcase_03 | AC | 86 ms
12,288 KB |
testcase_04 | AC | 84 ms
12,160 KB |
testcase_05 | AC | 91 ms
12,416 KB |
testcase_06 | AC | 343 ms
12,416 KB |
testcase_07 | AC | 85 ms
12,160 KB |
testcase_08 | AC | 89 ms
12,160 KB |
testcase_09 | AC | 88 ms
12,288 KB |
testcase_10 | AC | 169 ms
12,672 KB |
testcase_11 | AC | 181 ms
12,928 KB |
testcase_12 | AC | 150 ms
12,672 KB |
testcase_13 | AC | 176 ms
12,800 KB |
testcase_14 | AC | 200 ms
13,056 KB |
testcase_15 | AC | 197 ms
13,312 KB |
testcase_16 | AC | 97 ms
12,288 KB |
testcase_17 | AC | 119 ms
12,544 KB |
testcase_18 | AC | 194 ms
13,056 KB |
testcase_19 | AC | 218 ms
13,444 KB |
testcase_20 | AC | 223 ms
13,444 KB |
コンパイルメッセージ
Syntax OK
ソースコード
class Yukicoder def initialize t = gets.to_i @cache_good = Hash.new @cache_problem = Hash.new t.times do s = gets.chomp size = s.size min_dist = Float::INFINITY 0.upto(size - 7) do |i| dist1 = calc_dist_good(s[i..i+3]) (i+4).upto(size - 7) do |j| dist2 = calc_dist_problem(s[j..j+6]) min_dist = [min_dist, dist1 + dist2].min end end puts min_dist end end def calc_dist_good(str) return @cache_good[str] if @cache_good[str] dist = 0 0.upto(3) do |index| dist += 1 if str[index] != 'good'[index] end @cache_good[str] = dist end def calc_dist_problem(str) return @cache_problem[str] if @cache_problem[str] dist = 0 0.upto(6) do |index| dist += 1 if str[index] != 'problem'[index] end @cache_problem[str] = dist end end Yukicoder.new