CF2218B.The 67th 6-7 Integer Problem

入门

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

So, Macaque has passed his first challenge (and is not acknowledging your help whatsoever). After all, it was only given to him so he could engage in his greatest pleasure — crunching on desiccated freezedried hamburgers and yelling 'trivial' at the screen. However, he has another, much more important task ahead of him, and he has once again enlisted you to help him.

You are given $ 7 $ integers $ a_1, a_2, \ldots, a_7 $ .

You must negate $ 6 $ out of the $ 7 $ integers (that is, multiply them by $ -1 $ ). Over all possible ways to negate $ 6 $ out of the $ 7 $ integers, find the maximum possible sum of $ a $ .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 6767 $ ). The description of the test cases follows.

The first and only line of each test case contains $ 7 $ space-separated integers $ a_1, a_2, \ldots, a_7 $ ( $ -67 \le a_i \le 67 $ ).

输出格式

For each test case, output the maximum sum of $ a $ after negating $ 6 $ out of the $ 7 $ integers, on a new line.

输入输出样例

  • 输入#1

    4
    41 41 41 41 41 41 41
    6 9 4 20 6 7 67
    1 2 3 4 5 6 7
    6 7 6 7 6 7 6

    输出#1

    -205
    15
    -14
    -31

说明/提示

In the first test case, no matter which $ 6 $ integers we pick to negate, the maximum sum is $ -41-41-41-41-41-41+41=-205 $ .

In the second test case, we can negate all integers except $ a_7 $ to obtain a sum of $ -6-9-4-20-6-7+67=15 $ .

输入解题思路,AI测评打分。不知道怎么写?

首页