結果

問題 No.45 回転寿司
ユーザー MarioMario
提出日時 2019-07-08 06:55:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 388 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-16 16:50:42
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
11,008 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 30 ms
10,880 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 31 ms
10,752 KB
testcase_09 RE -
testcase_10 AC 32 ms
10,880 KB
testcase_11 AC 30 ms
10,880 KB
testcase_12 RE -
testcase_13 AC 30 ms
10,752 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 30 ms
10,752 KB
testcase_17 AC 32 ms
10,880 KB
testcase_18 AC 31 ms
10,880 KB
testcase_19 RE -
testcase_20 AC 30 ms
10,880 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 30 ms
10,880 KB
testcase_23 AC 31 ms
10,880 KB
testcase_24 AC 30 ms
10,752 KB
testcase_25 AC 30 ms
10,752 KB
testcase_26 AC 31 ms
10,880 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 30 ms
10,752 KB
testcase_32 AC 30 ms
10,752 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
v = list(map(int, input().split()))

memo = {}

def dp(i, f):
	if (i, f) in memo:
		return memo[(i, f)]
	else:
		memo[(i, f)] = dp_inner(i, f)
		return memo[(i, f)]

def dp_inner(i, f):

	if i == 0:
		return v[0] if f else 0
	else:
		
		if f:
			return max(dp(i-1, False) + v[i], dp(i-1, True))
		else:
			return dp(i-1, True)
	
print(max(dp(n-1, True), dp(n-1, False)))
0