結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2019-10-16 12:25:28 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 97 ms / 5,000 ms |
コード長 | 247 bytes |
コンパイル時間 | 38 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-06-11 20:54:47 |
合計ジャッジ時間 | 4,351 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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