Codeforces Round #429 (Div. 2), problem: (C) Leha and Function Solution In C/C++

#include<bits/stdc++.h>
using namespace std;
int main(){
std::ios::sync_with_stdio(false);
int m;
cin>>m;
int a[m],b[m];
for(int i=0;i<m;i++)
cin>>a[i];
vector<pair<int,int> >br(m);
for(int i=0;i<m;i++){

cin>>b[i];
br[i]=make_pair(b[i],i);
}
sort(a,a+m);
int ans[m];
sort(br.begin(),br.end());
reverse(br.begin(),br.end());
for(int i=0;i<m;i++)
ans[br[i].second]=a[i];
for(int i=0;i<m;i++)
cout<<ans[i]<<” “;

return 0;
}

(Visited 65 times, 1 visits today)

About the Author:

Leave A Comment