結果
| 問題 | No.204 ゴールデン・ウィーク(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-29 00:11:40 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 551 bytes |
| 記録 | |
| コンパイル時間 | 129 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-10-13 13:58:08 |
| 合計ジャッジ時間 | 5,388 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 33 |
コンパイルメッセージ
Syntax OK
ソースコード
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, c
if d == 0 || c == 14
return holiday(s)
else
ans = sol(d, s, c + 1)
if s[c] == 'x' && d > 0
s[c] = 'o'
ans = [sol(d - 1, s, c + 1), ans].max
s[c] = 'x'
end
return ans
end
end
d = gets.to_i
s = STDIN.map(&:chomp).join('')
p sol(d, s, 0)