結果

問題 No.999 てん vs. ほむ
ユーザー 👑 rin204
提出日時 2020-06-24 22:33:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 32,656 KB
最終ジャッジ日時 2024-07-03 20:24:06
合計ジャッジ時間 5,052 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
r = [0]
l = [0]
total = 0
for i in range(n):
    total += a[2 * i] - a[2 * i + 1]
    l.append(total)
total = 0
for i in range(n - 1, -1, -1):
    total += a[2 * i + 1] - a[2 * i]
    r.append(total)

ans = -10 ** 10
for rr, ll in zip(r, l[::-1]):
    ans = max(ans, rr + ll)
print(ans)
0