CF1843A Sasha and Array Coloring
题目描述
### 简要题意
给定一个长为 $n$ 的序列,你需要把每个元素分别染成一种颜色,颜色的种类数量不限。
每一种颜色的贡献为染成该色的数的极差。你需要最大化所有颜色贡献和,输出这个和。
输入格式
第一行为 $t$ ,表示数据组数。
对于每一组数据第一行为 $n$ 表示序列长度,第二行为一个长为 $n$ 的序列。
输出格式
每组数据输出一行一个数字,表示答案。
说明/提示
In the first example one of the optimal coloring is $ [\color{red}{1}, \color{red}{5}, \color{blue}{6}, \color{blue}{3}, \color{red}{4}] $ . The answer is $ (5 - 1) + (6 - 3) = 7 $ .
In the second example, the only possible coloring is $ [\color{blue}{5}] $ , for which the answer is $ 5 - 5 = 0 $ .
In the third example, the optimal coloring is $ [\color{blue}{1}, \color{red}{6}, \color{red}{3}, \color{blue}{9}] $ , the answer is $ (9 - 1) + (6 - 3) = 11 $ .