#include <iostream>
#include <vector>
using namespace std;
int main()
{
int person, num, sorce, i, j, tmp, pos;
bool panduan = false;
vector<int> a;
vector<int> b;
cin >> person;
while (person--)
{
panduan = false;
cin >> num >> sorce;
for (i = 0; i < a.size(); i++)
{
if (a[i] == num)
{
panduan = true;
b[i] += sorce;
break;
}
}
if (panduan == false)
{
a.push_back(num);
b.push_back(sorce);
}
}
tmp = b[0];
pos = 0;
for (i = 0; i < b.size(); i++)
{
if (b[i] > tmp)
{
pos = i;
tmp = b[i];
}
}
cout << a[pos] << " " << tmp;
return 0;
}
由于某种原因,最后一个测试点超时,不过思路没有问题。正确答案看这里。
我是真的菜