#include <iostream>
#include<map>
#include<vector>
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int k;
cin>>k;
map<int, vector<int>, greater<int>> m;
for(int i=0;i<n;i++){
m[a[i]].push_back(i+1);
}
int c=1;
for(auto i:m){
if(c>k){
break;
}
else{
cout<<"Rank "<<c<<" : ";
for(auto it:i.second){
cout<<it<<" ";
}
}
c++;
cout<<"\n";
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: