Source Code
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second

const int N = 2e5+2 ;
int n, m ;
int Ans[N] ;
pair<int, int>a[N], b[N] ;

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m ;
    for (int i = 1 ; i<= n ; i++)
        cin >> a[i].F, a[i].S = i ;

    for (int i = 1 ; i<= m ; i++)
        cin >> b[i].F, b[i].S = i  ;
    sort(a+1, a+1+n) ;
    sort(b+1, b+1+m) ;
    reverse(b+1, b+1+m) ;

    for (int i = 1 ; i<= m ; i++)
        Ans[b[i].S] = a[i].S ;
    for (int i =1 ; i<= m ; i++)
        cout<<Ans[i]<<" ";
}
Copy
Probability Game Mohammad.Nour
GNU G++17
49 ms
3.3 MB
Accepted