Codeforces Round 874 (Div. 3) 1833B - Restore the Weather Solution
Problem Link : https://codeforces.com/contest/1833/problem/B
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1e5+9 ;
- pair<int,int>a[N],b[N];
- int ans[N] ;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n , k ;
- cin >> n >> k ;
- for ( int i = 1 ; i <= n ; i++) {
- cin >> a[i].first;
- a[i].second = i ;
- }
- for ( int i = 1 ; i <= n ; i++) {
- cin >> b[i].first;
- b[i].second = i ;
- }
- sort( a + 1 , a + n + 1) ;
- sort( b + 1 , b + n + 1) ;
- for ( int i = 1 ; i <= n ; i++) {
- ans[a[i].second] = b[i].first ;
- }
- for ( int i = 1 ; i <= n ; i++) {
- cout << ans[i] <<" ";
- }
- cout <<"\n" ;
- }
- return 0;
- }
No comments