結果

問題 No.2854 -1 Subsequence
コンテスト
ユーザー rin204
提出日時 2024-08-25 15:00:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 183 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,892 KB
実行使用メモリ 104,568 KB
最終ジャッジ日時 2025-11-10 01:24:13
合計ジャッジ時間 4,117 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

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

x = -(1 << 60)
y = -(1 << 60)
for a in A:
    nx = max(x, y + a)
    ny = max(y, x - a, -a)
    x, y = nx, ny


print(max(x, y))
0