結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー fine
提出日時 2016-03-28 11:48:14
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 17,664 KB
最終ジャッジ日時 2024-10-13 13:57:51
合計ジャッジ時間 2,748 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other WA * 1 TLE * 1 -- * 44
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def holiday s
    s += 'x'
    tmp = ans = 0
    15.times{|i|
        if s[i] == 'o'
            tmp += 1
        else
            ans = [tmp, ans].max
            tmp = 0
        end
        }
    return ans
end

def sol d, s
    if d == 0
        return holiday(s)
    else
        ans = 0
        14.times{|i|
            if s[i] == 'x'
                s[i] = 'o'
                ans = [sol(d - 1, s), ans].max
                s[i] = 'x'
            end
            }
        return ans
    end
end 

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