結果

問題 No.999 てん vs. ほむ
ユーザー 👑 rin204rin204
提出日時 2020-06-24 22:33:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 339 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 30,764 KB
最終ジャッジ日時 2023-09-16 21:24:48
合計ジャッジ時間 3,858 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,916 KB
testcase_01 AC 16 ms
7,844 KB
testcase_02 AC 15 ms
7,816 KB
testcase_03 AC 14 ms
7,932 KB
testcase_04 AC 14 ms
7,856 KB
testcase_05 AC 15 ms
7,832 KB
testcase_06 AC 14 ms
7,780 KB
testcase_07 AC 14 ms
7,848 KB
testcase_08 AC 21 ms
8,900 KB
testcase_09 AC 178 ms
28,436 KB
testcase_10 AC 66 ms
14,268 KB
testcase_11 AC 45 ms
12,808 KB
testcase_12 AC 86 ms
17,216 KB
testcase_13 AC 193 ms
29,992 KB
testcase_14 AC 192 ms
30,024 KB
testcase_15 AC 190 ms
29,860 KB
testcase_16 AC 192 ms
29,860 KB
testcase_17 AC 162 ms
30,764 KB
testcase_18 AC 161 ms
28,988 KB
testcase_19 AC 170 ms
29,316 KB
testcase_20 AC 167 ms
29,404 KB
testcase_21 AC 157 ms
29,932 KB
testcase_22 AC 152 ms
29,324 KB
権限があれば一括ダウンロードができます

ソースコード

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