Source Code
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,m,y;
pair <ll,ll > a[100010];
ll b[100001],c[100001];
map <ll , pair <ll ,ll > > mp;
int main()
{
    cin >> n >> m;
    for (ll i=0;i<n;i++) {
        cin >> y;
        a[i]={y,i+1};
    }
    for (ll j=0;j<m;j++) {
        cin  >> b[j];
        c[j]=b[j];
    }
    sort(a,a+n);
    reverse (a,a+n);
    sort(b,b+m);
    ll x = n-m;
    for (ll i=0;i<m;i++) {
        mp[b[i]]=a[x+i];
    }
    for (ll i=0;i<m;i++) {
        cout << mp[c[i]].second << ' ';
    }
}
Copy
Probability Game MOohamed_Mahfouz
GNU G++11
8 ms
1.0 MB
Wrong Answer