結果

問題 No.45 回転寿司
ユーザー mationaruzoumationaruzou
提出日時 2020-05-01 21:02:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-24 20:40:36
合計ジャッジ時間 2,092 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 2 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

right = [0]*n
left = [0]*n
nowodd = 0
noweven = 0
for i in range(n):
    if i % 2 == 0:
        noweven = noweven+a[i]
        left[i] = noweven
    if i % 2 == 1:
        nowodd = nowodd+a[i]
        left[i] = nowodd
nowodd = 0
noweven = 0

for i in range(n-1, -1, -1):
    if i % 2 == 0:
        noweven = noweven+a[i]
        right[i] = (noweven)
    if i % 2 == 1:
        nowodd = nowodd+a[i]
        right[i] = (nowodd)
nux = 0
for i in range(n-3):
    if nux < left[i]+right[i+3]:
        nux = left[i]+right[i+3]
if n == 1:
    print(a[0])
else:
    print(max(nux, left[n-1], left[n-2]))
0