結果

問題 No.45 回転寿司
ユーザー shokayamorishokayamori
提出日時 2020-11-29 18:31:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 289 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 29,708 KB
最終ジャッジ日時 2023-10-11 02:30:11
合計ジャッジ時間 7,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
29,536 KB
testcase_01 AC 140 ms
29,548 KB
testcase_02 AC 134 ms
29,552 KB
testcase_03 AC 138 ms
29,636 KB
testcase_04 AC 136 ms
29,604 KB
testcase_05 AC 134 ms
29,644 KB
testcase_06 AC 134 ms
29,540 KB
testcase_07 AC 134 ms
29,556 KB
testcase_08 AC 133 ms
29,608 KB
testcase_09 AC 132 ms
29,632 KB
testcase_10 AC 134 ms
29,640 KB
testcase_11 AC 132 ms
29,708 KB
testcase_12 AC 132 ms
29,560 KB
testcase_13 AC 135 ms
29,672 KB
testcase_14 AC 133 ms
29,524 KB
testcase_15 AC 134 ms
29,612 KB
testcase_16 AC 135 ms
29,528 KB
testcase_17 AC 136 ms
29,536 KB
testcase_18 AC 133 ms
29,604 KB
testcase_19 AC 132 ms
29,584 KB
testcase_20 AC 133 ms
29,584 KB
testcase_21 AC 142 ms
29,528 KB
testcase_22 AC 135 ms
29,584 KB
testcase_23 AC 135 ms
29,644 KB
testcase_24 AC 132 ms
29,520 KB
testcase_25 AC 131 ms
29,644 KB
testcase_26 AC 134 ms
29,664 KB
testcase_27 AC 135 ms
29,696 KB
testcase_28 AC 135 ms
29,608 KB
testcase_29 AC 136 ms
29,544 KB
testcase_30 AC 141 ms
29,552 KB
testcase_31 AC 134 ms
29,628 KB
testcase_32 AC 138 ms
29,604 KB
testcase_33 AC 140 ms
29,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())
Vs = list(map(int, input().split()))

dp = np.full_like(Vs, -1)
for i in range(len(Vs)):
    if i == 0:
        dp[i] = Vs[i]
    elif i == 1:
        dp[i] = max(dp[i-1], Vs[i])
    else:
        dp[i] = max(dp[i-1], dp[i-2] + Vs[i]) 

print(dp[N-1])
0