Solution
2214-Inverse_Inversions.cpp
1#include <bits/stdc++.h>
2using namespace std;
3#define int long long
4
5signed main(){
6 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
7 int n,k; cin>>n>>k;
8 int res[n],l=1,r=n;
9 for(int i=0;i<n;++i){
10 if(k>=n-i-1) res[i]=r--,k-=n-i-1;
11 else res[i]=l++;
12 }
13 for(auto&x:res) cout<<x<<" "; cout<<'\n';
14 return 0;
15}Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.