https://pintia.cn/problem-sets/994805260223102976/problems/994805260990660608
#include <iostream>
#include <algorithm>
using namespace std;
struct node{
string name;
int x;
};
bool cmp(node a, node b){
return a.x < b.x;
}
node n[10010];
int main(){
int N;
cin >> N;
for(int i = 0; i < N; i++){
int a, b;
cin >> n[i].name >> a >> b;
n[i].x = a*a + b*b;
}
sort(n, n+N,cmp);
cout << n[0].name << " " << n[N-1].name ;
return 0;
}