~/algor $ cat problems/ochkoz-ishora-almashtirish
k sign flips
Easy
1000 ms
128 MB
24%
$n$ integers are given. In one operation you may flip the sign of any one number (replace $x$ with $-x$); the same number may be chosen several times. What is the largest possible sum of the numbers after exactly $k$ operations?
Input
The first line contains two positive integers: $n$ and $k$. The second line contains $n$ space-separated integers $a_{i}$.
Output
One integer — the largest sum.
Note
$1 \le n \le 10^{5}$
$1 \le k \le 10^{9}$
$-10^{9} \le a_{i} \le 10^{9}$
Examples
Input #1
5 3 -4 2 -1 3 -6
Output #1
16
Input #2
3 3 1 2 3
Output #2
4