結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー finefine
提出日時 2016-03-29 01:06:07
言語 Ruby
(3.2.2)
結果
AC  
実行時間 78 ms / 1,000 ms
コード長 705 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 15,316 KB
最終ジャッジ日時 2023-08-25 23:48:32
合計ジャッジ時間 5,163 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
15,132 KB
testcase_01 AC 71 ms
15,112 KB
testcase_02 AC 75 ms
15,060 KB
testcase_03 AC 68 ms
15,304 KB
testcase_04 AC 69 ms
15,096 KB
testcase_05 AC 69 ms
15,268 KB
testcase_06 AC 69 ms
15,100 KB
testcase_07 AC 74 ms
15,084 KB
testcase_08 AC 70 ms
15,140 KB
testcase_09 AC 71 ms
15,292 KB
testcase_10 AC 72 ms
15,284 KB
testcase_11 AC 76 ms
15,260 KB
testcase_12 AC 78 ms
15,112 KB
testcase_13 AC 76 ms
15,068 KB
testcase_14 AC 76 ms
15,316 KB
testcase_15 AC 71 ms
15,096 KB
testcase_16 AC 71 ms
15,080 KB
testcase_17 AC 72 ms
15,132 KB
testcase_18 AC 70 ms
15,012 KB
testcase_19 AC 70 ms
15,292 KB
testcase_20 AC 69 ms
15,280 KB
testcase_21 AC 71 ms
15,032 KB
testcase_22 AC 69 ms
15,080 KB
testcase_23 AC 71 ms
15,032 KB
testcase_24 AC 71 ms
15,196 KB
testcase_25 AC 67 ms
15,272 KB
testcase_26 AC 69 ms
15,276 KB
testcase_27 AC 71 ms
15,248 KB
testcase_28 AC 68 ms
15,084 KB
testcase_29 AC 70 ms
15,080 KB
testcase_30 AC 71 ms
15,240 KB
testcase_31 AC 73 ms
15,080 KB
testcase_32 AC 73 ms
15,264 KB
testcase_33 AC 72 ms
15,016 KB
testcase_34 AC 69 ms
15,136 KB
testcase_35 AC 71 ms
15,284 KB
testcase_36 AC 69 ms
15,128 KB
testcase_37 AC 71 ms
15,052 KB
testcase_38 AC 72 ms
15,084 KB
testcase_39 AC 73 ms
15,036 KB
testcase_40 AC 76 ms
15,272 KB
testcase_41 AC 72 ms
15,208 KB
testcase_42 AC 71 ms
15,276 KB
testcase_43 AC 70 ms
15,080 KB
testcase_44 AC 70 ms
15,060 KB
testcase_45 AC 70 ms
15,200 KB
testcase_46 AC 69 ms
15,284 KB
testcase_47 AC 68 ms
15,208 KB
testcase_48 AC 72 ms
15,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def sol d, s
    f = 'x'
    c = 0
    a = []
    15.times{|i|
        if s[i] == f
            c += 1
        else
            a.push(c)
            f = s[i]
            c = 1
        end
        }
    a.push(c)
    if a.size == 1
        return d
    else
        a.pop
        a.shift
        ans = [a[0] + d, a[-1] + d].max
        a.size.times{|i|
            if i % 2 == 0
                next
            end
            if a[i] > d
                ans = [ans, a[i - 1] + d, a[i + 1] + d].max
            else
                ans = [ans, a[i - 1] + a[i] + a[i + 1]].max
            end
            }
        return ans
    end
end

d = gets.to_i
s = STDIN.map(&:chomp).join('')
s += 'x'
p sol(d, s)
0