結果
| 問題 | No.45 回転寿司 |
| ユーザー |
|
| 提出日時 | 2019-10-16 12:25:28 |
| 言語 | Ruby (4.0.2) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 5,000 ms |
| + 137µs | |
| コード長 | 247 bytes |
| 記録 | |
| コンパイル時間 | 9 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 14,464 KB |
| 最終ジャッジ日時 | 2026-07-25 18:18:14 |
| 合計ジャッジ時間 | 3,494 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.to_i
A = [0] + gets.split.map(&:to_i)
d = Array.new(n + 1) { [0] * 2 }
d[0][0] = 0
d[0][1] = -Float::INFINITY
for i in (1..n)
d[i][0] = [d[i - 1][0], d[i - 1][1]].max
d[i][1] = d[i - 1][0] + A[i]
end
ans = d[n].max
puts ans