結果

問題 No.45 回転寿司
ユーザー souhei o
提出日時 2022-12-05 12:20:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-12 09:58:53
合計ジャッジ時間 2,107 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
w_list = [0]+list(map(int, input().split()))

def max_score(N, w_list):
    score_list=[0]*(N+1)
    score_list[1]=w_list[1]
    if N<2:
        return w_list[1]
    if w_list[1]>w_list[2]:
        score_list[2]=w_list[1]
    else:
        score_list[2]=w_list[2]
        
    for i in range(3, N+1):
        score1=score_list[i-2]+w_list[i]
        score2=score_list[i-1]
        if score1>score2:
            score_list[i]=score1
        else:
            score_list[i]=score2
            
    return score_list[N]
    
print(max_score(N, w_list))
0