题目:1032 挖掘机技术哪家强 (20 分)
来源:PAT (Basic Level) Practice
题面
思路:直接统计比较即可得出答案。
Code
点击查看代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200000];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,index,points,Max=-1,Mindex;
cin>>n;
for(ll i = 1;i<=n;i++){
cin>>index>>points;
a[index]+=points;
if(a[index]>Max){
Max = a[index];
Mindex = index;
}
}
cout<<Mindex<<" "<<Max<<"\n";
return 0;
}