Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #include <algorithm>
- #include <vector>
- #include <stack>
- #include <queue>
- #include <set>
- #include <map>
- using namespace std;
- int main(){
- map <int,int> mapa;
- map <int,int> mapa2;
- int n;
- int m;
- cin>>n;
- cin>>m;
- int a;
- int b;
- for(int i=0;i<n;i++){
- cin>>a;
- cin>>b;
- mapa[a]=b;
- }
- for (int i=0;i<m;i++){
- cin>>a;
- cin>>b;
- if (mapa2.empty()){if (mapa.find(a) != mapa.end()){ if (b>mapa[a]){mapa2[a]=b;};} }
- if (mapa2.empty()==false){if (mapa.find(a)!= mapa.end()) { if (b>mapa[a] and b>mapa2[a]){mapa2[a]=b;}
- }
- }
- }
- for(map<int,int>::iterator it=mapa2.begin(); it!=mapa2.end(); it++){
- cout<<it->first<<" "<<it->second<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement