結果

問題 No.999 てん vs. ほむ
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-02-28 22:05:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 109,932 KB
最終ジャッジ日時 2024-04-21 18:33:06
合計ジャッジ時間 3,006 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,840 KB
testcase_01 AC 35 ms
51,968 KB
testcase_02 AC 39 ms
51,624 KB
testcase_03 AC 35 ms
51,968 KB
testcase_04 AC 35 ms
52,224 KB
testcase_05 AC 34 ms
51,840 KB
testcase_06 AC 34 ms
51,968 KB
testcase_07 AC 34 ms
51,968 KB
testcase_08 AC 44 ms
62,208 KB
testcase_09 AC 86 ms
104,828 KB
testcase_10 AC 57 ms
77,696 KB
testcase_11 AC 49 ms
71,424 KB
testcase_12 AC 61 ms
83,968 KB
testcase_13 AC 101 ms
105,272 KB
testcase_14 AC 127 ms
104,968 KB
testcase_15 AC 102 ms
105,352 KB
testcase_16 AC 100 ms
104,968 KB
testcase_17 WA -
testcase_18 AC 86 ms
109,932 KB
testcase_19 WA -
testcase_20 AC 88 ms
109,700 KB
testcase_21 AC 103 ms
104,848 KB
testcase_22 AC 92 ms
107,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A = [(0, 0)]
for i in range(N):
    aa, bb = A[-1]
    A.append((aa+X[2*i], bb+X[2*i+1]))
aa, bb = 0, 0
r = -10**18
for i in range(N-1, -1, -1):
    b, a = X[2*i], X[2*i+1]
    r = max(r, A[i+1][0]-A[i+1][1]+aa-bb)
    aa += a
    bb += b

r = max(r, A[0][0]-A[0][1])
print(r)
0