結果

問題 No.45 回転寿司
ユーザー mkawa2mkawa2
提出日時 2020-01-02 22:47:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 559 ms / 5,000 ms
コード長 1,021 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 45,032 KB
最終ジャッジ日時 2024-05-02 06:46:22
合計ジャッジ時間 20,488 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 542 ms
44,912 KB
testcase_01 AC 549 ms
44,648 KB
testcase_02 AC 536 ms
44,752 KB
testcase_03 AC 539 ms
44,772 KB
testcase_04 AC 539 ms
44,900 KB
testcase_05 AC 542 ms
44,652 KB
testcase_06 AC 550 ms
44,768 KB
testcase_07 AC 554 ms
44,900 KB
testcase_08 AC 543 ms
44,652 KB
testcase_09 AC 540 ms
44,768 KB
testcase_10 AC 538 ms
44,776 KB
testcase_11 AC 556 ms
44,776 KB
testcase_12 AC 548 ms
44,652 KB
testcase_13 AC 550 ms
44,776 KB
testcase_14 AC 555 ms
44,648 KB
testcase_15 AC 544 ms
45,032 KB
testcase_16 AC 539 ms
44,904 KB
testcase_17 AC 547 ms
44,904 KB
testcase_18 AC 547 ms
44,772 KB
testcase_19 AC 536 ms
44,772 KB
testcase_20 AC 542 ms
44,648 KB
testcase_21 AC 559 ms
44,780 KB
testcase_22 AC 549 ms
44,908 KB
testcase_23 AC 558 ms
44,896 KB
testcase_24 AC 537 ms
44,900 KB
testcase_25 AC 542 ms
44,652 KB
testcase_26 AC 531 ms
44,656 KB
testcase_27 AC 547 ms
44,904 KB
testcase_28 AC 554 ms
44,904 KB
testcase_29 AC 552 ms
44,772 KB
testcase_30 AC 552 ms
44,772 KB
testcase_31 AC 550 ms
44,752 KB
testcase_32 AC 548 ms
44,780 KB
testcase_33 AC 544 ms
44,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import *
from bisect import *
#from math import *
from collections import *
from heapq import *
from random import *
from decimal import *
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    aa=LI()
    dp=[0]*(n+1)
    for i,a in enumerate(aa):
        if i-2>=0:dp[i+1]=max(dp[i-1],dp[i-2])+a
        elif i-1>=0:dp[i+1]=dp[i-1]+a
        else:dp[i+1]=a
    print(max(dp[n],dp[n-1]))

main()
0