开门人和关门人 hdu1234 水题

http://acm.hdu.edu.cn/showproblem.php?pid=1234

记录这个题再次记住,不能用time这个名字命名变量。要不然会出现编译错误。。

还有这次写用了运算符重载,记录一下格式吧。

#include <iostream>
#include <string>
using namespace std;
#define N 105

struct sj{
	int h,m,s;
};

struct record_node{
	string s;
	sj in,out;
};

record_node records[N];

bool operator>(sj a,sj b){
	if (a.h>b.h)
		return true;
	else if (a.h==b.h&&a.m>b.m)
		return true;
	else if (a.h==b.h&&a.m==b.m&&a.s>b.s)
		return true;
	return false;
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("1234in.txt","r",stdin);
#endif
	int m,n,i;
	string first,last;
	sj min,max;
	scanf("%d",&m);
	while (m--){
		scanf("%d",&n);
		for (i=0;i<n;i++){
			cin>>records[i].s;
			scanf("%d:%d:%d %d:%d:%d",&records[i].in.h,&records[i].in.m,&records[i].in.s,&records[i].out.h,&records[i].out.m,&records[i].out.s);
		}
		first=last=records[0].s;
		min=records[0].in;
		max=records[0].out;
		for (i=1;i<n;i++){
			if (min>records[i].in){
				min=records[i].in;
				first=records[i].s;
			}
			if (records[i].out>max){
				max=records[i].out;
				last=records[i].s;
			}
		}
		cout<<first<<' '<<last<<endl;
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值