#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int arr[100005] = {0}, t1, t2;
int maxid, maxscore = -1;
for (int i = 0; i < n; i++){
cin >> t1 >> t2;
arr[t1] += t2;
if (arr[t1] > maxscore){
maxscore = arr[t1];
maxid = t1;
}
}
cout << maxid << " " << maxscore;
return 0;
}
PAT/1032 挖掘机技术哪家强
于 2023-11-06 20:31:48 首次发布
这篇文章描述了一个C++程序,用于从用户输入中读取两个整数t1和t2,将t2的值累加到数组arr的相应位置,然后找到并输出数组中最大值的索引和值。
1972

被折叠的 条评论
为什么被折叠?



