309922: CF1760C. Advantage

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

Description

Advantage

题意翻译

若干个参赛者正在比拼。 每个人想要知道除自己以外的最厉害的人力量比自己**弱多少**,现在他们依次在向你询问。 Translated by @[CLCK](https://www.luogu.com.cn/user/323183)

题目描述

There are $ n $ participants in a competition, participant $ i $ having a strength of $ s_i $ . Every participant wonders how much of an advantage they have over the other best participant. In other words, each participant $ i $ wants to know the difference between $ s_i $ and $ s_j $ , where $ j $ is the strongest participant in the competition, not counting $ i $ (a difference can be negative). So, they ask you for your help! For each $ i $ ( $ 1 \leq i \leq n $ ) output the difference between $ s_i $ and the maximum strength of any participant other than participant $ i $ .

输入输出格式

输入格式


The input consists of multiple test cases. The first line contains an integer $ t $ ( $ 1 \leq t \leq 1000 $ ) — the number of test cases. The descriptions of the test cases follow. The first line of each test case contains an integer $ n $ ( $ 2 \leq n \leq 2\cdot10^5 $ ) — the length of the array. The following line contains $ n $ space-separated positive integers $ s_1 $ , $ s_2 $ , ..., $ s_n $ ( $ 1 \leq s_i \leq 10^9 $ ) — the strengths of the participants. It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 2\cdot10^5 $ .

输出格式


For each test case, output $ n $ space-separated integers. For each $ i $ ( $ 1 \leq i \leq n $ ) output the difference between $ s_i $ and the maximum strength of any other participant.

输入输出样例

输入样例 #1

5
4
4 7 3 5
2
1 2
5
1 2 3 4 5
3
4 9 4
4
4 4 4 4

输出样例 #1

-3 2 -4 -2 
-1 1 
-4 -3 -2 -1 1 
-5 5 -5 
0 0 0 0

说明

For the first test case: - The first participant has a strength of $ 4 $ and the largest strength of a participant different from the first one is $ 7 $ , so the answer for the first participant is $ 4 - 7 = -3 $ . - The second participant has a strength of $ 7 $ and the largest strength of a participant different from the second one is $ 5 $ , so the answer for the second participant is $ 7 - 5 = 2 $ . - The third participant has a strength of $ 3 $ and the largest strength of a participant different from the third one is $ 7 $ , so the answer for the third participant is $ 3 - 7 = -4 $ . - The fourth participant has a strength of $ 5 $ and the largest strength of a participant different from the fourth one is $ 7 $ , so the answer for the fourth participant is $ 5 - 7 = -2 $ .

Input

题意翻译

若干个参赛者正在比拼。 每个人想要知道除自己以外的最厉害的人力量比自己**弱多少**,现在他们依次在向你询问。 Translated by @[CLCK](https://www.luogu.com.cn/user/323183)

Output

**题目大意:**
在一场有n个参赛者参加的比赛中,每个参赛者i都有一个力量值s_i。每位参赛者都想知道他们与除自己之外最强的参赛者相比有多少优势。换句话说,参赛者i想知道自己的力量值s_i与比赛中最强的人(不包括自己)的力量值s_j的差值(差值可以为负)。对于每个参赛者i(1 ≤ i ≤ n),输出s_i与除参赛者i之外的任何参赛者的最大力量值之间的差值。

**输入输出数据格式:**
- **输入格式:**
输入包含多个测试案例。第一行包含一个整数t(1 ≤ t ≤ 1000)——测试案例的数量。接下来是每个测试案例的描述。
每个测试案例的第一行包含一个整数n(2 ≤ n ≤ 2·10^5)——数组的长度。
下一行包含n个以空格分隔的正整数s_1, s_2, ..., s_n(1 ≤ s_i ≤ 10^9)——参赛者的力量值。
保证所有测试案例的n之和不超过2·10^5。
- **输出格式:**
对于每个测试案例,输出n个以空格分隔的整数。对于每个i(1 ≤ i ≤ n),输出s_i与除参赛者i之外的任何参赛者的最大力量值之间的差值。**题目大意:** 在一场有n个参赛者参加的比赛中,每个参赛者i都有一个力量值s_i。每位参赛者都想知道他们与除自己之外最强的参赛者相比有多少优势。换句话说,参赛者i想知道自己的力量值s_i与比赛中最强的人(不包括自己)的力量值s_j的差值(差值可以为负)。对于每个参赛者i(1 ≤ i ≤ n),输出s_i与除参赛者i之外的任何参赛者的最大力量值之间的差值。 **输入输出数据格式:** - **输入格式:** 输入包含多个测试案例。第一行包含一个整数t(1 ≤ t ≤ 1000)——测试案例的数量。接下来是每个测试案例的描述。 每个测试案例的第一行包含一个整数n(2 ≤ n ≤ 2·10^5)——数组的长度。 下一行包含n个以空格分隔的正整数s_1, s_2, ..., s_n(1 ≤ s_i ≤ 10^9)——参赛者的力量值。 保证所有测试案例的n之和不超过2·10^5。 - **输出格式:** 对于每个测试案例,输出n个以空格分隔的整数。对于每个i(1 ≤ i ≤ n),输出s_i与除参赛者i之外的任何参赛者的最大力量值之间的差值。

加入题单

算法标签: