結果

問題 No.999 てん vs. ほむ
ユーザー O2MTO2MT
提出日時 2020-12-15 01:00:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 312 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 114,012 KB
最終ジャッジ日時 2023-10-20 05:32:52
合計ジャッジ時間 3,112 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,440 KB
testcase_01 AC 42 ms
53,376 KB
testcase_02 AC 40 ms
53,440 KB
testcase_03 AC 38 ms
53,440 KB
testcase_04 AC 38 ms
53,440 KB
testcase_05 AC 38 ms
53,440 KB
testcase_06 AC 38 ms
53,440 KB
testcase_07 AC 38 ms
53,440 KB
testcase_08 AC 46 ms
62,236 KB
testcase_09 AC 102 ms
103,852 KB
testcase_10 AC 59 ms
79,356 KB
testcase_11 AC 54 ms
73,160 KB
testcase_12 AC 66 ms
87,920 KB
testcase_13 AC 113 ms
110,960 KB
testcase_14 AC 111 ms
110,952 KB
testcase_15 AC 112 ms
110,964 KB
testcase_16 AC 111 ms
110,804 KB
testcase_17 AC 95 ms
114,012 KB
testcase_18 AC 94 ms
112,644 KB
testcase_19 AC 96 ms
114,012 KB
testcase_20 AC 96 ms
113,232 KB
testcase_21 AC 109 ms
110,552 KB
testcase_22 AC 100 ms
106,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(max(A)-min(A))
    exit()
B = []
for i in range(0,2*N-1,2):
    B.append(A[i]-A[i+1])

BC = list(accumulate(B))
ans = abs(BC[-1])

for i in range(len(BC)):
    ans = max(ans,BC[i]-(BC[-1]-BC[i]))
print(ans)
0