結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
d_nishiyama85
|
| 提出日時 | 2016-06-13 03:09:00 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 377 bytes |
| コンパイル時間 | 232 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 408,448 KB |
| 最終ジャッジ日時 | 2024-11-24 17:00:33 |
| 合計ジャッジ時間 | 94,798 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 TLE * 10 |
コンパイルメッセージ
Syntax OK
ソースコード
$n = gets.to_i
$v = gets.strip.split.map{|e| e.to_i}
$dp = {}
$n.times {|i| $dp[i] = {}}
def recursive i, now
if i >= $n
return now
end
if $dp[i].key?(now)
return $dp[i][now]
end
# 今回の皿を取る場合
a = recursive(i + 2, now + $v[i])
# 見送る場合
b = recursive(i + 1, now)
max = [a, b].max
$dp[i][now] = max
end
puts recursive 0, 0
d_nishiyama85