题解 | #开门人和关门人#

开门人和关门人

https://www.nowcoder.com/practice/a4b37b53a44d454ab0834e1517983215

#include<iostream>
#include<string>
#include<map>
#include<vector>
using namespace std;


//习题10.5  开门人和关门人 
int main()
{
	int n;
	cin >> n;
	map<string, vector<string>> maps;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		maps[s] = { "", "" };
		cin >> maps[s][0];
		cin >> maps[s][1];
	}
	string first = s, last = s, time = maps[s][0];
	for (auto it : maps) {
		if (it.second[0] < time) {
			time = it.second[0];
			first = it.first;
		}
	}
	time = maps[s][1];
	for (auto it : maps) {
		if (it.second[1] > time) {
			time = it.second[1];
			last = it.first;
		}
	}
	cout << first << " " << last << endl;

	return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 11:47
点赞 评论 收藏
分享
05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务