当前位置:网站首页>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;
}
边栏推荐
- [jetbrain rider] an exception occurred in the construction project: the imported project "d:\visualstudio2017\ide\msbuild\15.0\bin\roslyn\microsoft.csh" was not found
- UVM - configuration mechanism
- stm32和电机开发(上位系统)
- AttributeError: type object ‘Image‘ has no attribute ‘fromarray‘
- MYSQL环境配置
- STM32 and motor development (upper system)
- Rapid prototyping
- 两数之和,求目标值
- 2.hacking-lab脚本关[详细writeup]
- 13.信号量临界区保护
猜你喜欢
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
Kustomize使用手册
Session cookies and tokens
Use WinDbg to statically analyze dump files (summary of practical experience)
STM32 and motor development (upper system)
Pytest framework implements pre post
[visual studio] visual studio 2019 community version cmake development environment installation (download | install relevant components | create compilation execution project | error handling)
VLAN experiment
(5) Gear control setting of APA scene construction
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
随机推荐
Sum the two numbers to find the target value
14.信号量的代码实现
Sus system availability scale
1287_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
13.信号量临界区保护
Flink calculates topn hot list in real time
互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
Leetcode+ 76 - 80 storm search topic
4. Random variables
Lunix reallocates root and home space memory
VSCode工具使用
12.进程同步与信号量
《实习报告》Skywalking分布式链路追踪?
Database dictionary Navicat automatic generation version
Transport Optimization abstraction
JS reduce accumulator
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
flume 190 INSTALL
Delivery mode design of Spartacus UI of SAP e-commerce cloud
stm32和电机开发(上位系统)