Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- #include<algorithm>
- using namespace std;
- int main(){
- ifstream in;
- ofstream ou;
- in.open("input.txt");
- int n;
- in>>n;
- int mas=0;
- int c;
- for(int i=0;i<n;i++){
- in>>c;
- mas=max(mas,c);
- in>>c;
- }
- mas++;
- pair<int,int> array[mas];
- in.close();
- in.open("input.txt");
- in>>c;
- for(int i=0;i<n;i++){
- in>>c;
- array[c].first=0;
- array[c].second=c;
- in>>c;
- }
- in.close();
- in.open("input.txt");
- in>>c;
- int d;
- for(int i=0;i<n;i++){
- in>>c;
- in>>d;
- array[c].first+=d;
- }
- sort(array,array+mas);
- ou.open("output.txt");
- ou<<array[mas-1].second<<" "<<array[mas-1].first;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement