Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 2e6;
int n, m, a[N], b[N], an[N];
vector<pair<int,int>> in, out; 

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i<n; ++i){
       scanf("%d", a+i);
       in.push_back({a[i], i});
    }
    for(int i = 0; i<m; ++i){
      scanf("%d", b+i);
      out.push_back({b[i], i});
    }
    sort(all(in)), sort(all(out));
    reverse(all(out));
    for(int i = 0; i<m; ++i){
       an[out[i].second] = in[i].second; 
    }
    for(int i = 0; i<m; ++i)cout << an[i] + 1 << " ";
}
Copy
Probability Game molukhyyeh
GNU G++17
66 ms
4.2 MB
Accepted