結果

問題 No.999 てん vs. ほむ
ユーザー maspymaspy
提出日時 2020-03-02 21:15:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 719 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 53,884 KB
最終ジャッジ日時 2024-04-21 22:51:03
合計ジャッジ時間 16,918 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 546 ms
43,992 KB
testcase_01 AC 546 ms
43,960 KB
testcase_02 AC 544 ms
44,348 KB
testcase_03 AC 545 ms
44,472 KB
testcase_04 AC 535 ms
44,216 KB
testcase_05 AC 548 ms
44,344 KB
testcase_06 AC 548 ms
44,344 KB
testcase_07 AC 546 ms
44,088 KB
testcase_08 AC 531 ms
44,464 KB
testcase_09 AC 719 ms
52,304 KB
testcase_10 AC 583 ms
44,736 KB
testcase_11 AC 580 ms
44,472 KB
testcase_12 AC 596 ms
45,752 KB
testcase_13 AC 631 ms
53,612 KB
testcase_14 AC 621 ms
53,608 KB
testcase_15 AC 614 ms
53,612 KB
testcase_16 AC 577 ms
53,884 KB
testcase_17 AC 561 ms
52,168 KB
testcase_18 AC 583 ms
52,164 KB
testcase_19 AC 578 ms
52,656 KB
testcase_20 AC 564 ms
52,088 KB
testcase_21 AC 573 ms
53,452 KB
testcase_22 AC 608 ms
53,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
import numpy as np

# %%
N = int(readline())
A = np.array(read().split(), np.int64)

# %%
from_left = np.zeros(N + 1, np.int64)
from_left[1:] = (A[::2] - A[1::2]).cumsum()


# %%
from_right = np.zeros(N + 1, np.int64)
from_right[1:] = (A[::-1][::2] - A[::-1][1::2]).cumsum()
from_right = from_right[::-1]

# %%
answer = (from_left + from_right).max()
print(answer)
0