Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. #include<algorithm>
  4. using namespace std;
  5. int main(){
  6. ifstream in;
  7. ofstream ou;
  8. in.open("input.txt");
  9. int n;
  10. in>>n;
  11. int mas=0;
  12. int c;
  13. for(int i=0;i<n;i++){
  14. in>>c;
  15. mas=max(mas,c);
  16. in>>c;
  17. }
  18. mas++;
  19. pair<int,int> array[mas];
  20. in.close();
  21. in.open("input.txt");
  22. in>>c;
  23. for(int i=0;i<n;i++){
  24. in>>c;
  25. array[c].first=0;
  26. array[c].second=c;
  27. in>>c;
  28. }
  29. in.close();
  30. in.open("input.txt");
  31. in>>c;
  32. int d;
  33. for(int i=0;i<n;i++){
  34. in>>c;
  35. in>>d;
  36. array[c].first+=d;
  37. }
  38. sort(array,array+mas);
  39. ou.open("output.txt");
  40. ou<<array[mas-1].second<<" "<<array[mas-1].first;
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement