No.8103 Range Chmax and Maximize Abs Sum
レベル :
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 24
作問者 :
first_vil
/ テスター :
milkcoffee
タグ : / 解いたユーザー数 24
作問者 :
milkcoffee
問題文最終更新日: 2023-03-12 12:55:07
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder April Fool Contest 2023
(順位表)
の他の問題:
Problem Statement
There are $N$ integers arranged in a row from left to right on a table. You will now perform the following operation any number of times, possibly $0$ times.
- Choose integers $l,r\ (1 \le l \le r \le N)$. Replace all of the $l,l+1,\dots,r$-th integers from the left on the table with their maximum value.
Find the maximum possible value of the sum of the absolute values of the integers after the operations.
Input
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Line $1$ gives $N$, the number of integers arranged on the table. $N$ satisfies $1 \le N \le 200000$.
Line $2$ gives the $N$ integers $A_1,A_2,\dots,A_N$ arranged on the table, separated by single spaces. Each $A_i$ satisfies $-1000000000 \le A_i \le 1000000000$.
Output
Output the answer, followed by a newline.
Sample
Sample 1
Input
4 2 -2 1 -3
Output
9
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。