#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 xx, which is initially pp. Xiao \bot has a sequence aa of length nn. In one operation, Xiao T needs to perform the following changes in order:

  • Choose one number aia_i in aa.
  • Add aia_i to xx.
  • Set aia_i to its additive inverse, i.e., ai-a_i.

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 xx.

Input Format

The first line contains two integers n,pn, p.

The second line contains nn integers aia_i.

Output Format

Output one line with a single integer, representing the maximum possible value of xx.

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 a5=1a_5 = 1, then xx becomes 3+1=43 + 1 = 4, and a5a_5 becomes 1-1.
  • Choose a1=1a_1 = 1, then xx becomes 4+1=54 + 1 = 5, and a1a_1 becomes 1-1.
  • Choose a3=4a_3 = -4, then xx becomes 54=15 - 4 = 1, and a3a_3 becomes 44.
  • Choose a4=5a_4 = 5, then xx becomes 1+5=61 + 5 = 6, and a4a_4 becomes 5-5.
  • Choose a2=1a_2 = 1, then xx becomes 6+1=76 + 1 = 7, and a2a_2 becomes 1-1.
  • Choose a3=4a_3 = 4, then xx becomes 7+4=117 + 4 = 11, and a3a_3 becomes 4-4.

It can be proven that the maximum value of xx is 1111. Note that it is not only the plan shown in the sample that can achieve this maximum value.

Constraints

Test Point ID nn \le Special Property
131 \sim 3 2020
454 \sim 5 10510^5 ai<0a_i < 0
676 \sim 7 ai0a_i \ge 0
8108 \sim 10

For 100%100\% of the data, 1n1051 \le n \le 10^5, ai,p109|a_i|, |p| \le 10^9.

Translated by ChatGPT 5