Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <stack>
  7. #include <queue>
  8. #include <set>
  9. #include <map>
  10. using namespace std;
  11. int main(){
  12. map <int,int> mapa;
  13. map <int,int> mapa2;
  14. int n;
  15. int m;
  16. cin>>n;
  17. cin>>m;
  18. int a;
  19. int b;
  20. for(int i=0;i<n;i++){
  21. cin>>a;
  22. cin>>b;
  23. mapa[a]=b;
  24. }
  25. for (int i=0;i<m;i++){
  26. cin>>a;
  27. cin>>b;
  28. if (mapa2.empty()){if (mapa.find(a) != mapa.end()){ if (b>mapa[a]){mapa2[a]=b;};} }
  29. if (mapa2.empty()==false){if (mapa.find(a)!= mapa.end()) { if (b>mapa[a] and b>mapa2[a]){mapa2[a]=b;}
  30.  
  31. }
  32.  
  33.  
  34. }
  35. }
  36. for(map<int,int>::iterator it=mapa2.begin(); it!=mapa2.end(); it++){
  37.  
  38. cout<<it->first<<" "<<it->second<<endl;
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement