首页 > 其他 > 详细

浙江大学机试 开门人和关门人 Easy

时间:2020-03-14 10:44:51      阅读:71      评论:0      收藏:0      [点我收藏+]

基本思想:

无;

 

关键点:

无;

 

#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;

bool flag;

struct node{
	string id;
	int sh;
	int sm;
	int ss;
	int eh;
	int em;
	int es;
};

vector<node>vec;

bool cmp(node a, node b) {
	if (flag) {
		//找早到的;
		if (a.sh != b.sh) {
			return a.sh < b.sh;
		}
		else if (a.sm != b.sm) {
			return a.sm < b.sm;
		}
		else {
			return a.ss < b.ss;
		}
	}
	else {
		if (a.eh != b.eh) {
			return a.eh > b.eh;
		}
		else if (a.em != b.em) {
			return a.em > b.em;
		}
		else {
			return a.es < b.es;
		}
	}
}

void init() {
	vec.resize(0);
	flag = true;
}

int main() {
	int n;
	while (cin >> n) {
		flag = true;
		for (int i = 0; i < n; i++) {
			node no;
			cin >> no.id;
			scanf("%d:%d:%d %d:%d:%d", &no.sh, &no.sm, &no.ss, &no.eh, &no.em, &no.es);
			vec.push_back(no);
		}
		sort(vec.begin(), vec.end(), cmp);
		cout << vec[0].id;
		flag = false;
		sort(vec.begin(), vec.end(), cmp);
		cout << " " << vec[0].id << endl;;
	}
}

  

浙江大学机试 开门人和关门人 Easy

原文:https://www.cnblogs.com/songlinxuan/p/12490239.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!