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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int main(){
    FAST
    int n, m; cin >> n >> m;
    vector<pair<int, int> > v1, v2;
    int ans[m];
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        v1.pb({a, i});
    }
    for(int i = 0; i < m; i++){
        int b; cin >> b;
        v2.pb({b, i});
    }
    sort(v1.begin(), v1.end());
    sort(v2.rbegin(), v2.rend());
    for(int i = 0; i < m; i++){
        ans[v2[i].second] = v1[i].second + 1;
    }
    for(int i = 0; i < m; i++){
        cout << ans[i] << " ";
    }
    return 0;
}
Copy
Probability Game Basilhijaz
GNU G++17
76 ms
3.4 MB
Accepted