Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int n;
- int sum = 0;
- int main () {
- cin >> n;
- int minn = 1e+9;
- int k = 0;
- for (int i = 0; i <= (2 * (n - 1)); i++) {
- int t;
- cin >> t;
- if (t < 0)
- k++;
- sum += abs(t);
- minn = min (minn, abs(t));
- }
- if (k >= n ) {
- k -= n;
- }
- if (!(k % 2)) {
- cout << sum;
- } else {
- cout << sum - 2 * minn;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment