-
Notifications
You must be signed in to change notification settings - Fork 4k
/
CodeChef Snack Down 2021 Qualifiers
59 lines (50 loc) · 1.05 KB
/
CodeChef Snack Down 2021 Qualifiers
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<bits/stdc++.h>
using namespace std;
#define tc ll t sc cin>> t sc while(t--)
#define ff first
#define sc ;
#define ss second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define Radhe ios::sync_with_stdio(false);
#define Krishna cin.title(NULL);
bool cmp(pair<ll, ll> &a, pair<ll, ll>&b)
{
return a.second < b.second;
}
int main()
{
tc
{
ll n , x;
cin>>n;
vector<pair<ll, ll>> arr;
for(int i=0;i<n;i++)
{
cin>>x;
arr.push_back(make_pair(x,i));
}
ll k=0;
sort(arr.begin(), arr.end());
for(int i=0;i<n;i++)
{
if(arr[i].first>k)
{
arr[i].first =k;
k++;
}
else if (arr[i].first==k)
{
arr[i].first = k;
}
}
sort(arr.begin(), arr.end(),cmp);
for(int i=0; i<n;i++)
{
cout<<arr[i].first<<" ";
}
cout<<"\n";
}
}