Stevie Hackerearth

code:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prl(x) printf("%lld\n",x)
#define clr(x) memset(x,0,sizeof(x))
const int N=2e5+55; //max range 10^9

int n,a[N],b[N];
map<int,int> mpp; //<key value, mapped value>
//vector<int> A(n), B(n);
//cin>>n;
int main()
{
    sc(n);
    for(int i=1; i<=n; i++)
    {
        sc(a[i]);
    }
    for(int i=1; i<=n; i++)
    {
        sc(b[i]);
    }
    for(int i=1; i<=n; i++)
    {
        mpp[a[i]]=max(b[i],mpp[a[i]]);
    }
    for(int i=1; i<=n; i++)
    {
        cout<<mpp[a[i]]<<" ";
    }

}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.