Created
November 21, 2022 17:44
-
-
Save qjatn0120/bd6ab1391b10a2dde8ce18fcba7f3ef0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int MX = 2e5 + 5; | |
int t, n, arr[MX]; | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
cin >> t; | |
while(t--){ | |
cin >> n; | |
for(int i = 0; i < n; i++) cin >> arr[i]; | |
int idx = max_element(arr, arr + n) - arr; | |
int num = 0; | |
for(int i = 0; i < n; i++){ | |
if(idx == i) continue; | |
num = max(num, arr[i]); | |
} | |
for(int i = 0; i < n; i++){ | |
if(i == idx) cout << (arr[i] - num) << " "; | |
else cout << (arr[i] - arr[idx]) << " "; | |
} | |
cout << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment