Create 1082.射击比赛.cpp

This commit is contained in:
hao14293
2018-11-26 11:57:35 +08:00
committed by GitHub
parent 6e39d6a27e
commit 7cb271e0e4

View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct score{
int id;
int num;
};
bool cmp(score a, score b){
return a.num < b.num;
}
int main(){
int n, id, x, y;
cin >> n;
vector<score> v(n);
for(int i = 0 ; i < n; i++){
cin >> id >> x >> y;
v[i].id = id;
v[i].num = x * x + y * y;
}
sort(v.begin(), v.end(), cmp);
printf("%04d %04d", v[0].id, v[n - 1].id);
return 0;
}