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

开门人和关门人

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

#include <bits/stdc++.h>

using namespace std;

typedef struct People{
	string num;
	string open_time;
	string close_time;
	
}People;

vector<People> p;

bool cmp_open(People p1, People p2){
	return p1.open_time < p2.open_time;
}

bool cmp_close(People p1, People p2){
	return p1.close_time > p2.close_time;
}
int main(){
	
	int n;
	cin >> n;
	for (int i=0; i<n; i++){
		string num;
		string open_time;
		string close_time;
		cin >> num >> open_time >> close_time;
		p.push_back({num, open_time, close_time});
	}
	sort(p.begin(), p.end(), cmp_open);
	cout << p[0].num << " ";
	sort(p.begin(), p.end(), cmp_close);
	cout << p[0].num << endl;
	return 0;
}

全部评论

相关推荐

03-05 12:52
吉林大学 Java
挣K存W养DOG:他的价值在于把他家里积攒的财富回馈给社会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务