結果

問題 No.999 てん vs. ほむ
ユーザー c-yanc-yan
提出日時 2020-03-22 00:26:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 10,840 KB
実行使用メモリ 30,968 KB
最終ジャッジ日時 2023-08-25 17:57:38
合計ジャッジ時間 5,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,868 KB
testcase_01 AC 15 ms
7,852 KB
testcase_02 AC 14 ms
7,776 KB
testcase_03 AC 15 ms
7,944 KB
testcase_04 AC 15 ms
7,800 KB
testcase_05 AC 15 ms
7,796 KB
testcase_06 AC 15 ms
7,880 KB
testcase_07 AC 15 ms
7,796 KB
testcase_08 AC 21 ms
8,892 KB
testcase_09 AC 218 ms
28,348 KB
testcase_10 AC 76 ms
14,084 KB
testcase_11 AC 55 ms
12,556 KB
testcase_12 AC 105 ms
17,308 KB
testcase_13 AC 240 ms
29,976 KB
testcase_14 AC 242 ms
30,048 KB
testcase_15 AC 243 ms
29,976 KB
testcase_16 AC 242 ms
30,016 KB
testcase_17 AC 223 ms
30,968 KB
testcase_18 AC 216 ms
29,144 KB
testcase_19 AC 222 ms
29,268 KB
testcase_20 AC 224 ms
29,456 KB
testcase_21 AC 237 ms
29,976 KB
testcase_22 AC 226 ms
29,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

l = A[::2]
r = A[1::2]
for i in range(N - 1):
    l[i + 1] += l[i]
    r[i + 1] += r[i]

result = l[N - 1] - r[N - 1]
result = max(result, r[N - 1] - l[N - 1])
for i in range(1, N):
    t = l[N - 1 - i] + (r[N - 1] - r[N - 1 - i])
    t -= r[N - 1 - i] + (l[N - 1] - l[N - 1 - i])
    result = max(result, t)
print(result)
0