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

By | 2017-08-21T13:16:20+00:00 August 21st, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#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; }