結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー simansiman
提出日時 2016-03-25 17:26:50
言語 Ruby
(3.2.2)
結果
AC  
実行時間 77 ms / 1,000 ms
コード長 766 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-08-25 23:48:25
合計ジャッジ時間 5,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
15,172 KB
testcase_01 AC 70 ms
15,036 KB
testcase_02 AC 74 ms
15,160 KB
testcase_03 AC 68 ms
15,104 KB
testcase_04 AC 71 ms
15,232 KB
testcase_05 AC 73 ms
15,208 KB
testcase_06 AC 73 ms
15,256 KB
testcase_07 AC 71 ms
15,176 KB
testcase_08 AC 72 ms
15,084 KB
testcase_09 AC 68 ms
15,324 KB
testcase_10 AC 71 ms
15,328 KB
testcase_11 AC 72 ms
15,300 KB
testcase_12 AC 68 ms
15,136 KB
testcase_13 AC 70 ms
15,128 KB
testcase_14 AC 69 ms
15,080 KB
testcase_15 AC 70 ms
15,212 KB
testcase_16 AC 73 ms
15,216 KB
testcase_17 AC 68 ms
15,192 KB
testcase_18 AC 68 ms
15,168 KB
testcase_19 AC 72 ms
15,208 KB
testcase_20 AC 73 ms
15,152 KB
testcase_21 AC 73 ms
15,288 KB
testcase_22 AC 71 ms
15,224 KB
testcase_23 AC 72 ms
15,092 KB
testcase_24 AC 71 ms
15,104 KB
testcase_25 AC 77 ms
15,084 KB
testcase_26 AC 77 ms
15,160 KB
testcase_27 AC 71 ms
15,128 KB
testcase_28 AC 70 ms
15,080 KB
testcase_29 AC 68 ms
15,040 KB
testcase_30 AC 69 ms
15,252 KB
testcase_31 AC 72 ms
15,156 KB
testcase_32 AC 71 ms
15,068 KB
testcase_33 AC 73 ms
15,084 KB
testcase_34 AC 72 ms
15,276 KB
testcase_35 AC 69 ms
15,136 KB
testcase_36 AC 71 ms
15,284 KB
testcase_37 AC 71 ms
15,076 KB
testcase_38 AC 72 ms
15,244 KB
testcase_39 AC 71 ms
15,144 KB
testcase_40 AC 73 ms
15,012 KB
testcase_41 AC 71 ms
15,068 KB
testcase_42 AC 72 ms
15,196 KB
testcase_43 AC 72 ms
15,240 KB
testcase_44 AC 72 ms
15,172 KB
testcase_45 AC 70 ms
15,072 KB
testcase_46 AC 71 ms
15,292 KB
testcase_47 AC 71 ms
15,292 KB
testcase_48 AC 75 ms
15,064 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    @d = gets.to_i

    @week = "x" * 14
    @week += gets.chomp
    @week += gets.chomp
    @week += "x" * 14
    answer = 0

    0.upto(@week.size-1) do |i|
      temp = @week.dup

      set_renkyu(i)
      answer = [answer, get_renkyu].max

      @week = temp.dup
    end

    puts answer
  end

  def set_renkyu(i)
    count = 0

    while @week[i] == 'x' && count < @d
      @week[i] = 'o'
      i += 1 
      count += 1
    end
  end

  def get_renkyu
    renkyu = 0
    max_renkyu = 0

    @week.chars do |ch|
      if ch == 'o'
        renkyu += 1
      else
        max_renkyu = [max_renkyu, renkyu].max
        renkyu = 0
      end
    end

    max_renkyu = [max_renkyu, renkyu].max

    max_renkyu
  end
end

Yukicoder.new
0