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

开门人和关门人

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-02 13:50
闽江学院 Java
点赞 评论 收藏
分享
zhch7:建议9✌️把学历加黑加粗,如果实在offer可能是觉得佬不会去
投了多少份简历才上岸
点赞 评论 收藏
分享
05-14 20:34
门头沟学院 Java
窝补药贝八股:管他们,乱说,反正又不去,直接说680
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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