結果

問題 No.999 てん vs. ほむ
ユーザー ronpooronpoo
提出日時 2023-09-28 10:43:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 1,388 ms
コンパイル使用メモリ 86,440 KB
実行使用メモリ 112,428 KB
最終ジャッジ日時 2023-09-28 10:43:52
合計ジャッジ時間 4,983 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,216 KB
testcase_01 AC 73 ms
70,976 KB
testcase_02 AC 71 ms
71,132 KB
testcase_03 AC 73 ms
71,100 KB
testcase_04 AC 73 ms
71,092 KB
testcase_05 AC 73 ms
71,156 KB
testcase_06 AC 72 ms
70,780 KB
testcase_07 AC 73 ms
70,976 KB
testcase_08 AC 88 ms
76,132 KB
testcase_09 AC 141 ms
108,360 KB
testcase_10 AC 92 ms
85,084 KB
testcase_11 AC 91 ms
80,772 KB
testcase_12 AC 100 ms
90,860 KB
testcase_13 AC 143 ms
112,260 KB
testcase_14 AC 142 ms
112,264 KB
testcase_15 AC 144 ms
112,268 KB
testcase_16 AC 143 ms
112,428 KB
testcase_17 AC 124 ms
103,232 KB
testcase_18 AC 122 ms
103,196 KB
testcase_19 AC 122 ms
103,212 KB
testcase_20 AC 121 ms
103,384 KB
testcase_21 AC 139 ms
112,428 KB
testcase_22 AC 139 ms
111,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0
odd = [0]
odd_r = [0]
sa = 0
for i in range(N):
    odd.append(odd[-1] + A[i*2])
    odd_r.append(odd_r[-1] + A[2*N-1-(i*2)])
    sa += A[2*i] + A[2*i+1]
odd_r.reverse()

ans = abs(odd[-1]-sa+odd[-1])
for i in range(N):
    a = odd[i+1] + odd_r[i+1]
    b = odd_r[i] + odd[i]    
    ans = max(ans, a-sa+a, b-sa+b)
print(ans)
0