結果

問題 No.45 回転寿司
ユーザー howakurohowakuro
提出日時 2018-12-02 01:59:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 534 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2023-09-09 13:48:19
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,336 KB
testcase_01 AC 16 ms
8,248 KB
testcase_02 AC 17 ms
8,428 KB
testcase_03 AC 18 ms
8,372 KB
testcase_04 AC 16 ms
8,380 KB
testcase_05 AC 15 ms
7,848 KB
testcase_06 AC 16 ms
8,340 KB
testcase_07 AC 16 ms
8,424 KB
testcase_08 AC 15 ms
8,112 KB
testcase_09 AC 17 ms
8,356 KB
testcase_10 AC 16 ms
8,200 KB
testcase_11 AC 16 ms
8,120 KB
testcase_12 AC 17 ms
8,576 KB
testcase_13 AC 15 ms
7,772 KB
testcase_14 AC 15 ms
7,804 KB
testcase_15 AC 16 ms
8,260 KB
testcase_16 AC 16 ms
8,344 KB
testcase_17 AC 16 ms
8,344 KB
testcase_18 AC 16 ms
8,276 KB
testcase_19 AC 16 ms
8,348 KB
testcase_20 AC 15 ms
7,820 KB
testcase_21 AC 14 ms
7,884 KB
testcase_22 AC 15 ms
7,748 KB
testcase_23 AC 15 ms
7,912 KB
testcase_24 AC 15 ms
7,776 KB
testcase_25 AC 14 ms
7,848 KB
testcase_26 AC 15 ms
8,288 KB
testcase_27 AC 16 ms
8,364 KB
testcase_28 AC 15 ms
8,396 KB
testcase_29 AC 16 ms
8,260 KB
testcase_30 AC 16 ms
8,428 KB
testcase_31 AC 14 ms
7,912 KB
testcase_32 AC 15 ms
7,860 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

memo = {}
def kaitenzusi(susi_number,before_get):
    if (susi_number,before_get) in memo:
        return memo[(susi_number,before_get)]
    if susi_number == N:
        return 0
    not_get = 0 
    if before_get == False:
        not_get = kaitenzusi(susi_number+1, True) + V[susi_number]
    get = kaitenzusi(susi_number+1, False)
    memo[(susi_number,before_get)] = not_get if not_get > get else get
    return memo[(susi_number,before_get)]

N = int(input())
V = [int(num) for num in input().split()]
print(kaitenzusi(0, False))
0