結果

問題 No.45 回転寿司
ユーザー けむけむけむけむ
提出日時 2021-06-17 15:00:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 539 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 11,928 KB
最終ジャッジ日時 2023-08-30 22:28:43
合計ジャッジ時間 2,502 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
9,400 KB
testcase_01 AC 31 ms
10,048 KB
testcase_02 AC 40 ms
11,764 KB
testcase_03 AC 43 ms
11,928 KB
testcase_04 AC 32 ms
10,312 KB
testcase_05 AC 20 ms
8,604 KB
testcase_06 AC 29 ms
9,844 KB
testcase_07 AC 39 ms
11,472 KB
testcase_08 AC 22 ms
8,964 KB
testcase_09 AC 43 ms
11,792 KB
testcase_10 AC 26 ms
9,396 KB
testcase_11 AC 22 ms
8,812 KB
testcase_12 AC 42 ms
11,844 KB
testcase_13 AC 21 ms
8,672 KB
testcase_14 AC 20 ms
8,560 KB
testcase_15 AC 28 ms
9,620 KB
testcase_16 AC 23 ms
9,012 KB
testcase_17 AC 26 ms
9,308 KB
testcase_18 AC 23 ms
8,972 KB
testcase_19 AC 36 ms
11,020 KB
testcase_20 AC 20 ms
8,668 KB
testcase_21 AC 19 ms
8,652 KB
testcase_22 AC 19 ms
8,624 KB
testcase_23 AC 19 ms
8,584 KB
testcase_24 AC 19 ms
8,520 KB
testcase_25 AC 19 ms
8,612 KB
testcase_26 AC 27 ms
9,536 KB
testcase_27 AC 35 ms
11,068 KB
testcase_28 AC 27 ms
9,748 KB
testcase_29 AC 34 ms
10,708 KB
testcase_30 AC 35 ms
10,872 KB
testcase_31 AC 19 ms
8,508 KB
testcase_32 AC 19 ms
8,512 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

@lru_cache(maxsize=1000)
def osusi(N, V):
    if N == 1:
        return V[0]
    pat = [0, 0, 0, 0, V[-2], V[-1]]
    if N - 2 >= 1:
        pat[0] = osusi(N - 2, V[:N - 2]) + V[-1]
    if N - 3 >= 1:
        pat[1] = osusi(N - 3, V[:N - 3]) + V[-1]
        pat[2] = osusi(N - 3, V[:N - 3]) + V[-2]
    if N - 4 >= 1:
        pat[3] = osusi(N - 4, V[:N - 4]) + V[-2]
    return max(pat)

if __name__ == '__main__':
    N = int(input())
    V_li = tuple(map(int, input().split()))
    print(osusi(N, V_li))
0