Advertisement
Ankit_132

C

Feb 17th, 2024
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int t;
  7.     cin>>t;
  8.    
  9.     while(t--){
  10.         int n;
  11.         cin>>n;
  12.  
  13.         vector<int> a(n);
  14.         for(auto &e: a)     cin>>e;
  15.  
  16.         for(int i=0; i<n; i++)
  17.             a[i] += i+1;
  18.  
  19.         sort(a.rbegin(), a.rend());
  20.  
  21.         int val = 2e9;
  22.  
  23.         for(auto e: a)
  24.         {
  25.             if(e >= val)
  26.             {
  27.                 cout<<val-1<<" ";
  28.                 val--;
  29.             }
  30.             else
  31.             {
  32.                 cout<<e<<" ";
  33.                 val = e;
  34.             }
  35.         }
  36.  
  37.         cout<<"\n";
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement