1082 射击比赛 (20 point(s))

虽然是水题还是看了下别人的写法,似乎可以不需要容器,在读取的时候记录最大最小的平方和,最后直接输出即可。这样还能剩一下空间和排序的时间。

参考代码

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, x, y;
	map<int, string> player;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		string name;
		cin >> name >> x >> y;
		player[x * x + y * y] = name;		
	}
	cout << player.begin()->second << " " << player.rbegin()->second;
}

posted on 2021-09-16 22:51  Atl212  阅读(32)  评论(0)    收藏  举报

导航