Source Code
#include<bits/stdc++.h>
#define ll long long 

using namespace std;
ll MOD = 1e9+7;
ll bigMod(ll x,ll y){
    if (y == 1)return x;
    ll res = bigMod(x , y / 2LL);
    res *= res;
    res %= MOD;
    if (y % 2){
        res *= x;
        res %= MOD;
    }
    return res;
}

int n , m ;
vector<pair<int,int> > v1 , v2;
int ans[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    for (int i=0;i<n;i++){
        int x;
        cin >> x;
        v1.push_back({x , i + 1});
    }
    sort(v1.begin(),v1.end());
    for (int i=0;i<m;i++){
        int x;
        cin >> x;
        v2.push_back({x , i });
    }
    sort(v2.rbegin(),v2.rend());
    for (int i=0;i<m;i++){
        ans[v2[i].second] = v1[i].second;
    }
    for (int i=0;i<m;i++)cout << ans[i] << " ";
    
    return 0;
}
Copy
Probability Game Khaled97ha
GNU G++17
46 ms
3.3 MB
Accepted