-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvantage.cpp
More file actions
33 lines (30 loc) · 748 Bytes
/
Advantage.cpp
File metadata and controls
33 lines (30 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// problem statement link: https://codeforces.com/contest/1760/problem/C
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n,temp;
cin >> n;
vector<int> v1,v2;
for (int i = 0; i < n; i++) {
cin >> temp;
v1.push_back(temp);
v2.push_back(temp);
}
sort(v2.begin(), v2.end());
int max = v2[n - 1];
int secMax = v2[n - 2];
for (int i = 0; i < n; i++) {
if (v1[i] == max)
cout << v1[i] - secMax << " ";
else
cout << v1[i] - max << " ";
}
cout << "\n";
}
return 0;
}