#P8480. 「HGOI-1」PMTD

「HGOI-1」PMTD

Background

uuku\text{uuku} is learning the four basic arithmetic operations!

Problem Description

To check uuku\text{uuku}'s learning results, bh1234666\text{bh1234666} gives an integer sequence aia_i of length nn, and asks uuku\text{uuku} to perform mm operations on this sequence.

In each operation, you may choose any number aia_i in the sequence and change aia_i into one of the following four results: ai+2a_i+2, ai2a_i-2, ai×2a_i\times 2, ai2\lfloor\frac{a_i}{2}\rfloor.

bh1234666\text{bh1234666} wants the range (maximum value minus minimum value) of the whole sequence to be as large as possible after mm operations.

Obviously, uuku\text{uuku} did not study carefully, so he wants you to help answer this question.

Input Format

The first line contains two integers nn and mm.

The second line contains nn integers, representing the sequence aia_i.

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 22 to 11 to get 33.

In the second operation, multiply 33 by 22 to get 66.

The range is 60=66-0=6.

Constraints

This problem uses bundled tests. There are 22 subtask\text{subtask}s, and the final score is the sum of the scores of all subtask\text{subtask}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 100%100\% of the testdata, 2n1062 \le n \le 10^6, 1m101 \le m \le 10, 0ai1090 \le a_i \le 10^9.

Translated by ChatGPT 5