VisaOA #13
Maximum Sum by Sign-Flip Pairs
估计中等可在线判题
Each operation picks two distinct positions and multiplies both by −1; operations can be repeated. Find the maximum sum the array can reach.
输入格式
n (2≤n≤200000), n integers (−10⁹..10⁹). From the source problem's constraints.
输出格式
Output the maximum sum, using a 64-bit integer.
样例 1
输入:
3
-5 -1 7
输出:
13
样例 2
输入:
2
-2 -3
输出:
5
样例 3
输入:
3
0 -5 8
输出:
13