1006. Sign In and Sign Out (25)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked
the door on that day.

Input Specification:

Each input file contains one test case. Each case contains the records for one day. The case starts with a positive integer M, which is the total number of records, followed by M lines, each in the format:

ID_number Sign_in_time Sign_out_time

where times are given in the format HH:MM:SS, and ID number is a string with no more than 15 characters.

Output Specification:

For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.

Note: It is guaranteed that the records are consistent. That is, the sign in time must be earlier than the sign out time for each person, and there are no two persons sign in or out at the same moment.

Sample Input:

3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40

Sample Output:

SC3021234 CS301133

#include<iostream>
#include<string>
using namespace std;
struct node
{
char name[100];
int h1, h2, m1, m2, s1, s2;
}person[10000];
bool compare(int h1,int m1,int s1,int h2,int m2,int s2)
{
if (h1 < h2)
return 1;
if (h1>h2)
return 0;
if (m1 < m2)
return 1;
if (m1>m2)
return 0;
if (s1 < s2)
return 1;
if (s1>s2)
return 0;
return 0;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%s %d:%d:%d %d:%d:%d", &person[i].name, &person[i].h1, &person[i].m1, &person[i].s1, &person[i].h2, &person[i].m2, &person[i].s2);
int flag1 = 0;
int flag2=0;
for (int i = 0; i < n; i++)
{
if (compare(person[i].h1, person[i].m1, person[i].s1, person[flag1].h1, person[flag1].m1, person[flag1].s1))
{
flag1 = i;
}
if (!compare(person[i].h2, person[i].m2, person[i].s2, person[flag2].h2, person[flag2].m2, person[flag2].s2))
{
flag2 = i;
}
}
printf("%s %s\n", person[flag1].name, person[flag2].name);
return 0;
}


PAT甲 1006. Sign In and Sign Out (25) 2016-09-09 22:55 43人阅读 评论(0) 收藏的更多相关文章

  1. PAT甲 1007. Maximum Subsequence Sum (25) 2016-09-09 22:56 41人阅读 评论(0) 收藏

    1007. Maximum Subsequence Sum (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...

  2. PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏

    1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  3. PAT甲 1002. A+B for Polynomials (25) 2016-09-09 22:50 64人阅读 评论(0) 收藏

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  4. PAT甲 1046. Shortest Distance (20) 2016-09-09 23:17 22人阅读 评论(0) 收藏

    1046. Shortest Distance (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...

  5. PAT甲 1048. Find Coins (25) 2016-09-09 23:15 29人阅读 评论(0) 收藏

    1048. Find Coins (25) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves t ...

  6. PAT甲 1041. Be Unique (20) 2016-09-09 23:14 33人阅读 评论(0) 收藏

    1041. Be Unique (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Being uniqu ...

  7. PAT甲 1032. Sharing (25) 2016-09-09 23:13 27人阅读 评论(0) 收藏

    1032. Sharing (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To store Engl ...

  8. PAT甲 1029. Median (25) 2016-09-09 23:11 27人阅读 评论(0) 收藏

    1029. Median (25) 时间限制 1000 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given an incr ...

  9. PAT甲 1012. The Best Rank (25) 2016-09-09 23:09 28人阅读 评论(0) 收藏

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

随机推荐

  1. 【342】Linear Regression by Python

    Reference: 用scikit-learn和pandas学习线性回归 首先获取数据存储在 pandas.DataFrame 中,获取途径(CSV 文件.Numpy 创建) 将数据分成 X 和 y ...

  2. 用java编写一个函数,用于计算桌子的面积,可计算任意边长的桌子

    /* *桌子实体类,有属性和方法 */public class Table {    String name; // 声明桌子名称    Double width; // 声明桌子宽度    Doub ...

  3. session第二篇

    二 A.application对象 1.application对象实现了用户间数据的共享,可存放全局变量. 2.application对象开始于服务器的启动,终止于服务器的关闭. 3.在用户的前后连接 ...

  4. IIS中利用ARR实现反向代理

    反向代理是什么,不了解的,请自行百度.本人也是最近才研究这个主题,简单的来说,利用这项技术可以实现负载均衡,安全控制等web应用中重要的功能,对于web应用来说这是个很基础,也很重要的技术,值得开发者 ...

  5. go 格式化时间戳

    func main() { //获取时间戳 timestamp := time.Now().Unix() fmt.Println(timestamp) //格式化为字符串,tm为Time类型 tm : ...

  6. oracle改变表中列的编码

    ALTER TABLE table_name CHANGE `name` `name` VARCHAR(255) CHARACTER SET utf8;

  7. gorm中数据库datetime类型的映射和time.Time的格式化

    如果在结构体中设置time变量的类型是time.Time,那么gorm取出来的时间格式将会是”2006-01-02 15:04:05.999999999 -0700 MST“东八区时间,在time.T ...

  8. TensorFlow—张量运算仿真神经网络的运行

    import tensorflow as tf import numpy as np ts_norm=tf.random_normal([]) with tf.Session() as sess: n ...

  9. The Doors(几何+最短路,好题)

    The Doors http://poj.org/problem?id=1556 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions ...

  10. Asp.net中FileUpload控件实现图片上传并带预览显示

    单一图片上传——“选择”+“上传”,.NET默认模式: 1.实现原理:     采用FileUpload控件默认的使用方式,先由“选择”按钮选择图片,然后单击“上传”按钮完成上传,并可在“上传”按钮的 ...