1082 射击比赛
题目链接:1082 射击比赛
代码如下:
#include<iostream>
#include<map>
using namespace std;
int main()
{
int n;
cin>>n;
map<string,double> mp;
for(int i=0;i < n;i++)
{
string name;
int x,y;
cin>>name>>x>>y;
double dis = x*x+y*y;
mp[name] = dis;
}
double max=0,min=100000000;
string big,small;
for(auto it = mp.begin();it != mp.end();it++)
{
if(it->second > max)
{
max = it->second;
big = it->first;
}
if(it->second < min)
{
min = it->second;
small = it->first;
}
}
cout<<small<<" "<<big;
return 0;
}