結果

問題 No.999 てん vs. ほむ
ユーザー masa_aamasa_aa
提出日時 2020-02-28 21:47:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 32,664 KB
最終ジャッジ日時 2024-04-21 18:17:58
合計ジャッジ時間 4,238 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 29 ms
10,624 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 32 ms
11,520 KB
testcase_09 AC 200 ms
30,500 KB
testcase_10 AC 83 ms
16,564 KB
testcase_11 AC 65 ms
15,616 KB
testcase_12 AC 111 ms
19,428 KB
testcase_13 AC 237 ms
32,664 KB
testcase_14 AC 243 ms
32,548 KB
testcase_15 AC 244 ms
32,536 KB
testcase_16 AC 245 ms
32,664 KB
testcase_17 AC 214 ms
29,120 KB
testcase_18 AC 216 ms
28,824 KB
testcase_19 AC 215 ms
29,096 KB
testcase_20 AC 213 ms
29,156 KB
testcase_21 AC 208 ms
32,640 KB
testcase_22 AC 206 ms
31,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=[a[i]-a[i+1] for i in range(0,2*n,2)]
c=[-i for i in b]
b=[0]+b
c+=[0]
for i in range(1,n+1):
    b[i]+=b[i-1]
for i in range(n-1,-1,-1):
    c[i]+=c[i+1]
ans=-10**18
for i in range(n+1):
    ans=max(ans,b[i]+c[i])
print(ans)
0