#P11035. 【MX-X3-T2】「RiOI-4」消えた夏の夢
【MX-X3-T2】「RiOI-4」消えた夏の夢
Background
Original link: https://oier.team/problems/X3C。
Let’s keep talking, just the two of us, forever
About the summer that has ended,
And gently bring the dreams we were searching for
To an end, so that we never go back.
It’s goodbye.
The voice I wished would reach you
Turned into the wind, and slipped through
The gaps in my heart.
—— "The Vanished Summer Dream"
Xiao T cannot set problems.
Problem Description
Xiao T has a number , which is initially . Xiao has a sequence of length . In one operation, Xiao T needs to perform the following changes in order:
- Choose one number in .
- Add to .
- Set to its additive inverse, i.e., .
Xiao T wants to know: after performing some operations (it is allowed to perform no operation, and the same position may be chosen multiple times), what is the maximum possible value of .
Input Format
The first line contains two integers .
The second line contains integers .
Output Format
Output one line with a single integer, representing the maximum possible value of .
6 3
1 1 -4 5 1 -4
11
7 4
1 -9 -1 -9 8 -1 0
13
Hint
Sample Explanation #1
For the sample, you can perform the following operations in order:
- Choose , then becomes , and becomes .
- Choose , then becomes , and becomes .
- Choose , then becomes , and becomes .
- Choose , then becomes , and becomes .
- Choose , then becomes , and becomes .
- Choose , then becomes , and becomes .
It can be proven that the maximum value of is . Note that it is not only the plan shown in the sample that can achieve this maximum value.
Constraints
| Test Point ID | Special Property | |
|---|---|---|
For of the data, , .
Translated by ChatGPT 5