結果

問題 No.999 てん vs. ほむ
ユーザー wattaiheiwattaihei
提出日時 2020-02-28 21:27:14
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 242 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 10,536 KB
実行使用メモリ 30,168 KB
最終ジャッジ日時 2023-08-03 19:33:57
合計ジャッジ時間 3,650 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,836 KB
testcase_01 AC 16 ms
7,836 KB
testcase_02 AC 16 ms
7,804 KB
testcase_03 AC 16 ms
7,880 KB
testcase_04 AC 16 ms
7,752 KB
testcase_05 AC 16 ms
7,780 KB
testcase_06 AC 16 ms
7,820 KB
testcase_07 AC 15 ms
7,796 KB
testcase_08 AC 20 ms
8,900 KB
testcase_09 AC 153 ms
27,908 KB
testcase_10 AC 56 ms
13,908 KB
testcase_11 AC 43 ms
12,024 KB
testcase_12 AC 75 ms
16,840 KB
testcase_13 AC 164 ms
30,000 KB
testcase_14 AC 164 ms
30,016 KB
testcase_15 AC 164 ms
30,024 KB
testcase_16 AC 163 ms
29,960 KB
testcase_17 AC 145 ms
30,168 KB
testcase_18 AC 142 ms
28,968 KB
testcase_19 AC 145 ms
30,104 KB
testcase_20 AC 144 ms
28,436 KB
testcase_21 AC 143 ms
29,936 KB
testcase_22 AC 139 ms
29,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

B = [0]
for i in range(N):
    b = A[2*i]-A[2*i+1]
    B.append(B[-1]+b)


S = B[-1]
ans = -10**15
for b in B:
    ans = max(ans, 2*b - S)
print(ans)
0