当前位置:网站首页>HDU1234 开门人和关门人(水题)
HDU1234 开门人和关门人(水题)
2022-07-02 07:04:00 【Woodenman杜】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1234
Question
Problem Description
每天第一个到机房的人要把门打开,最后一个离开的人要把门关好。现有一堆杂乱的机房签
到、签离记录,请根据记录找出当天开门和关门的人。
Input
测试输入的第一行给出记录的总天数N ( > 0 )。下面列出了N天的记录。
每天的记录在第一行给出记录的条目数M ( > 0 ),下面是M行,每行的格式为:
证件号码 签到时间 签离时间
其中时间按“小时:分钟:秒钟”(各占2位)给出,证件号码是长度不超过15的字符串。
Output
对每一天的记录输出1行,即当天开门和关门人的证件号码,中间用1空格分隔。
注意:
在裁判的标准测试输入中,所有记录保证完整,每个人的签到时间在签离时间之前,
且没有多人同时签到或者签离的情况。

Solve
一堆时间里找出最小的和最大的,注意格式控制就行
AC Code
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int t, n;
int main(void)
{
scanf("%d", &t);
while(t--){
scanf("%d", &n);
string en, st; //起止证件号
int t_en = -1, t_st = 1e9; //起止时间
int h1, h2, m1, m2, s1, s2;
for(int i = 1; i <= n; i++){
string s; cin >>s;
//读入时间
scanf("%02d:%02d:%02d", &h1, &m1, &s1);
scanf("%02d:%02d:%02d", &h2, &m2, &s2);
//计算
int t1 = h1 * 3600 + m1 * 60 + s1;
int t2 = h2 * 3600 + m2 * 60 + s2;
//比较
if(t1 < t_st) { st = s; t_st = t1; }
if(t2 > t_en) { en = s; t_en = t2; }
}
cout <<st <<" " <<en <<endl;
}
return 0;
}边栏推荐
- Flutter环境配置保姆级教程,让doctor一绿到底
- What are the popular frameworks for swoole in 2022?
- Internet News: Tencent conference application market was officially launched; Soul went to Hong Kong to submit the listing application
- 数据库字典Navicat自动生成版本
- [Fantasy 4] introduction and use of UMG components (under update...)
- 01-spooldir
- Ks009 implement pet management system based on SSH
- Read H264 parameters from mediarecord recording
- 12. Process synchronization and semaphore
- 高考的意义是什么
猜你喜欢

(5) Gear control setting of APA scene construction

1287_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析

AI技术产业热点分析
![[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces](/img/6f/e5a30dae824ccb22d1157818be58be.png)
[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces

互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书

sqoop创建job出现的一系列问题解决方法

Pytest-- test report allure configuration

JS reduce accumulator

Pytest framework implements pre post
![[SUCTF2018]followme](/img/63/9104f9c8bd24937b0fc65053efec96.png)
[SUCTF2018]followme
随机推荐
Redis set password
Thanos Receiver
Pytest learning --base
使用Windbg静态分析dump文件(实战经验总结)
Pywin32 opens the specified window
stm32和電機開發(上比特系統)
13. Semaphore critical zone protection
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
JS reduce accumulator
【TS】1368- 秒懂 TypeScript 泛型工具类型!
Solution of mysql8 forgetting password file in Windows Environment
集成学习概览
Set the playback speed during the playback of UOB equipment
2022-06-17
12.进程同步与信号量
PCL 投影点云
PCL之K-d树与八叉树
js promise.all
(五)APA场景搭建之挡位控制设置
14. Code implementation of semaphore