結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-02-02 18:14:56 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 344 bytes |
コンパイル時間 | 820 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,528 KB |
最終ジャッジ日時 | 2024-12-27 12:48:46 |
合計ジャッジ時間 | 2,611 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
def dfs(i,n): global N global V global dp if i >= N:return 0 if dp[n][i] != -1:return dp[n][i] ret = 0 ret = max(ret,dfs(i + 2,n) + V[i]) ret = max(ret,dfs(i + 3,n) + V[i]) dp[n][i] = ret return dp[n][i] N = int(raw_input()) V = map(int,raw_input().split()) dp = [[-1 for j in range(N)] for i in range(2)] print max(dfs(0,0),dfs(1,1))