#P8480. 「HGOI-1」PMTD
「HGOI-1」PMTD
Background
is learning the four basic arithmetic operations!
Problem Description
To check 's learning results, gives an integer sequence of length , and asks to perform operations on this sequence.
In each operation, you may choose any number in the sequence and change into one of the following four results: , , , .
wants the range (maximum value minus minimum value) of the whole sequence to be as large as possible after operations.
Obviously, did not study carefully, so he wants you to help answer this question.
Input Format
The first line contains two integers and .
The second line contains integers, representing the sequence .
Output Format
One line with one integer, representing the maximum possible range.
3 2
0 1 0
6
Hint
Sample Explanation
In the first operation, add to to get .
In the second operation, multiply by to get .
The range is .
Constraints
This problem uses bundled tests. There are s, and the final score is the sum of the scores of all s.
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|}\hline \textbf{Task} & \textbf{Score} & \textbf{Special Constraints} \cr\hline 1 & 40 & n \le 5,m \le 5 \cr\hline 2 & 60 & \cr\hline \end{array}$$For of the testdata, , , .
Translated by ChatGPT 5