結果

問題 No.45 回転寿司
ユーザー shi-moshi-mo
提出日時 2016-03-28 13:04:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 196 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 11,280 KB
実行使用メモリ 21,072 KB
最終ジャッジ日時 2023-08-27 14:39:12
合計ジャッジ時間 4,026 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
16,368 KB
testcase_01 AC 84 ms
17,332 KB
testcase_02 AC 79 ms
19,284 KB
testcase_03 AC 79 ms
20,024 KB
testcase_04 AC 77 ms
17,484 KB
testcase_05 AC 73 ms
15,268 KB
testcase_06 AC 77 ms
16,876 KB
testcase_07 AC 79 ms
19,260 KB
testcase_08 AC 77 ms
15,920 KB
testcase_09 AC 79 ms
19,604 KB
testcase_10 AC 77 ms
16,352 KB
testcase_11 AC 74 ms
15,884 KB
testcase_12 AC 78 ms
19,588 KB
testcase_13 AC 73 ms
15,132 KB
testcase_14 AC 73 ms
15,296 KB
testcase_15 AC 76 ms
16,748 KB
testcase_16 AC 76 ms
15,956 KB
testcase_17 AC 78 ms
16,408 KB
testcase_18 AC 79 ms
16,292 KB
testcase_19 AC 80 ms
18,548 KB
testcase_20 AC 74 ms
15,028 KB
testcase_21 AC 77 ms
15,156 KB
testcase_22 AC 74 ms
15,216 KB
testcase_23 AC 75 ms
15,228 KB
testcase_24 AC 76 ms
15,084 KB
testcase_25 AC 76 ms
15,088 KB
testcase_26 AC 79 ms
16,716 KB
testcase_27 AC 79 ms
18,492 KB
testcase_28 AC 76 ms
16,896 KB
testcase_29 AC 81 ms
17,924 KB
testcase_30 AC 78 ms
18,420 KB
testcase_31 AC 73 ms
15,136 KB
testcase_32 AC 75 ms
15,304 KB
testcase_33 AC 78 ms
21,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
v = [nil] + gets.chomp!.split.map(&:to_i)

dp_a = [ 0, v[1] ] # scores include i-th dish

2.upto(n) do |i|
  dp_a[i] = v[i] + dp_a[0..(i-2)].max
end

puts [ dp_a[n], dp_a[n-1] ].max
0