Source Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void lets_hope_its_right(){
    int n,m; cin>>n>>m;
    vector<pair<int,int>>a(n),b(m);
    vector<int>c(m);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    for(int i=0;i<m;i++){
        cin>>b[i].first;
        b[i].second=i;
    }
    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());
    for(int i=0;i<m;i++){
        c[b[i].second]=a[i].second;
    }
    for(int i=0;i<m;i++) cout<<c[i]+1<<' ';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt=1; //cin>>tt;
    while(tt--) lets_hope_its_right();
}
Copy
Probability Game YazanIstatiyeh
GNU G++17
49 ms
3.3 MB
Accepted