結果

問題 No.999 てん vs. ほむ
ユーザー brthyyjp
提出日時 2020-03-28 18:52:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 116,540 KB
最終ジャッジ日時 2025-01-02 12:00:21
合計ジャッジ時間 3,335 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

cL = [0]*(n+1)
cR = [0]*(n+1)

L = []
R = []
for i in range(2*n):
    if i%2 == 0:
        L.append(A[i])
    else:
        R.append(A[i])

R.reverse()
for i in range(n):
    cL[i+1] = cL[i]+L[i]
    cR[i+1] = cR[i]+R[i]

ans = 0
for i in range(n+1):
    j = n-i
    ans = max(ans, cL[i]+cR[j])
print(2*ans-sum(A))
0