https://i1.wp.com/eblogarithm.com/wp-content/uploads/2017/08/Codeforces-Round-429-Div-2-problem-C-Leha-and-Function-Solution-In-CC1.png?fit=640%2C360

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 44 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: