We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */inta[1003]={0};intb[1003]={0};intn,x;cin>>n;inta1[n],b1[n];for(inti=0;i<n;i++){cin>>x;a[x]++;}for(inti=0;i<n;i++){cin>>x;b[x]++;}intc=0;for(inti=0;i<1002;i++){if(a[i]>0&&b[i]>0){c+=(min(a[i],b[i]));}}if(c<n){cout<<c+1<<endl;}else{cout<<c-1<<endl;}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Pairs
You are viewing a single comment's thread. Return to all comments →
here my solutions