301590: CF301A. Yaroslav and Sequence

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Yaroslav and Sequence

题意翻译

### 题目描述 现有 $2n-1$ 个整数,每次操作可以使其中的 $n$ 个数 $\times (-1)$。 现在请问进行任意次操作后,这些整数的最大和是多少? --- ### 输入格式 输入共两行。第一行包含一个整数 $n$。 第二行包含 $2n-1$ 个数,表示所给的整数。 --- ### 输出格式 输出一个整数,表示最大和。 --- ### 数据范围 对于 $100\%$ 的数据,$1\le n\le100,1\le|x|\le1000$

题目描述

Yaroslav has an array, consisting of $ (2·n-1) $ integers. In a single operation Yaroslav can change the sign of exactly $ n $ elements in the array. In other words, in one operation Yaroslav can select exactly $ n $ array elements, and multiply each of them by -1. Yaroslav is now wondering: what maximum sum of array elements can be obtained if it is allowed to perform any number of described operations? Help Yaroslav.

输入输出格式

输入格式


The first line contains an integer $ n $ $ (2<=n<=100) $ . The second line contains $ (2·n-1) $ integers — the array elements. The array elements do not exceed $ 1000 $ in their absolute value.

输出格式


In a single line print the answer to the problem — the maximum sum that Yaroslav can get.

输入输出样例

输入样例 #1

2
50 50 50

输出样例 #1

150

输入样例 #2

2
-1 -100 -1

输出样例 #2

100

说明

In the first sample you do not need to change anything. The sum of elements equals $ 150 $ . In the second sample you need to change the sign of the first two elements. Then we get the sum of the elements equal to $ 100 $ .

Input

题意翻译

### 题目描述 现有 $2n-1$ 个整数,每次操作可以使其中的 $n$ 个数 $\times (-1)$。 现在请问进行任意次操作后,这些整数的最大和是多少? --- ### 输入格式 输入共两行。第一行包含一个整数 $n$。 第二行包含 $2n-1$ 个数,表示所给的整数。 --- ### 输出格式 输出一个整数,表示最大和。 --- ### 数据范围 对于 $100\%$ 的数据,$1\le n\le100,1\le|x|\le1000$

加入题单

算法标签: