#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
typedef struct
{
int x,y;
}number;
bool cmp(number a,number b)
{
if(a.x!=b.x)
return a.x<b.x;
else return a.y<b.y;
}
int main() {
int n;
while (cin >> n) { // 注意 while 处理多个 case
number num[1000];
for(int i=0;i<n;i++)
{
cin>>num[i].x>>num[i].y;
}
sort(num,num+n,cmp);
cout<<num[0].x<<" "<<num[0].y<<endl;
}
}
// 64 位输出请用 printf("%lld")
开始想用map来避免处理冗余数据,但是后来想到map好像没办法直接用sort排序,直接用数组的话只要按顺序从索引为0的位置开始输入,然后排序时只排前n位,也可以避免处理到冗余数据,最后输出第一位的数据即可

京公网安备 11010502036488号