309655: CF1714A. Everyone Loves to Sleep

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Everyone Loves to Sleep

题意翻译

### 题目描述 Vlad和其他人一样,非常喜欢睡觉。 Vlad每天都要做 $n$ 件事,每件事在特定时间。对于这些事情中的每一件,他都定了一个闹钟,其中第 $i$ 个在 $h_i$ 时 $m_i$ 分被触发($0\le h_i<24,0\le m_i<60)$。 Vlad使用24小时时间格式,所以12:59之后是13:00,23:59后是00:00。 Vlad在H时M分睡觉($0 \le H < 24, 0 \le M < 60$)。 他要你回答:在下一个闹钟响之前,他能睡多久。 如果在他上床睡觉的时候有任何闹钟响起,那么他将睡0小时0分钟。 ### 输入格式 输入数据的第一行包含一个整数 $t$ ($1 \le t \le 100$) — 测试中测试用例的数量。 每组测试用例的第一行包含三个整数 $n$ , $H$ 和 $M$ ($ 1 \le n \le 10, 0 \le H < 24, 0 \le M < 60$) — 闹钟的数量和Vlad上床睡觉的时间。 以下 $n$ 行各包含两个数字 $h_i$ 和 $m_i$ ( $0 \le h_i < 24, 0 \le m_i < 60$) — 每个闹钟响的时间。两个或多个闹钟可以同时响起。描述时间的数字不包含前导零。 ### 输出格式 输出 $t$ 行,每行都包含相应测试用例的答案。 作为答案,输出两个数字 - Vlad将分别睡觉的小时数和分钟数。如果在他上床睡觉的时候有任何闹钟响起,答案将是 $0\ 0$。 ### 样例解释 对于第一个测试用例,Vlad上床后第一个响的闹钟是8:00的。 对于第二个测试用例,Vlad上床时有闹钟响起。 对于第三个测试用例,Vlad上床后第一个响的闹钟是第二天10:30的。

题目描述

Vlad, like everyone else, loves to sleep very much. Every day Vlad has to do $ n $ things, each at a certain time. For each of these things, he has an alarm clock set, the $ i $ -th of them is triggered on $ h_i $ hours $ m_i $ minutes every day ( $ 0 \le h_i < 24, 0 \le m_i < 60 $ ). Vlad uses the $ 24 $ -hour time format, so after $ h=12, m=59 $ comes $ h=13, m=0 $ and after $ h=23, m=59 $ comes $ h=0, m=0 $ . This time Vlad went to bed at $ H $ hours $ M $ minutes ( $ 0 \le H < 24, 0 \le M < 60 $ ) and asks you to answer: how much he will be able to sleep until the next alarm clock. If any alarm clock rings at the time when he went to bed, then he will sleep for a period of time of length $ 0 $ .

输入输出格式

输入格式


The first line of input data contains an integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases in the test. The first line of the case contains three integers $ n $ , $ H $ and $ M $ ( $ 1 \le n \le 10, 0 \le H < 24, 0 \le M < 60 $ ) — the number of alarms and the time Vlad went to bed. The following $ n $ lines contain two numbers each $ h_i $ and $ m_i $ ( $ 0 \le h_i < 24, 0 \le m_i < 60 $ ) — the time of the $ i $ alarm. It is acceptable that two or more alarms will trigger at the same time. Numbers describing time do not contain leading zeros.

输出格式


Output $ t $ lines, each containing the answer to the corresponding test case. As an answer, output two numbers — the number of hours and minutes that Vlad will sleep, respectively. If any alarm clock rings at the time when he went to bed, the answer will be 0 0.

输入输出样例

输入样例 #1

3
1 6 13
8 0
3 6 0
12 30
14 45
6 0
2 23 35
20 15
10 30

输出样例 #1

1 47
0 0
10 55

Input

题意翻译

### 题目描述 Vlad和其他人一样,非常喜欢睡觉。 Vlad每天都要做 $n$ 件事,每件事在特定时间。对于这些事情中的每一件,他都定了一个闹钟,其中第 $i$ 个在 $h_i$ 时 $m_i$ 分被触发($0\le h_i<24,0\le m_i<60)$。 Vlad使用24小时时间格式,所以12:59之后是13:00,23:59后是00:00。 Vlad在H时M分睡觉($0 \le H < 24, 0 \le M < 60$)。 他要你回答:在下一个闹钟响之前,他能睡多久。 如果在他上床睡觉的时候有任何闹钟响起,那么他将睡0小时0分钟。 ### 输入格式 输入数据的第一行包含一个整数 $t$ ($1 \le t \le 100$) — 测试中测试用例的数量。 每组测试用例的第一行包含三个整数 $n$ , $H$ 和 $M$ ($ 1 \le n \le 10, 0 \le H < 24, 0 \le M < 60$) — 闹钟的数量和Vlad上床睡觉的时间。 以下 $n$ 行各包含两个数字 $h_i$ 和 $m_i$ ( $0 \le h_i < 24, 0 \le m_i < 60$) — 每个闹钟响的时间。两个或多个闹钟可以同时响起。描述时间的数字不包含前导零。 ### 输出格式 输出 $t$ 行,每行都包含相应测试用例的答案。 作为答案,输出两个数字 - Vlad将分别睡觉的小时数和分钟数。如果在他上床睡觉的时候有任何闹钟响起,答案将是 $0\ 0$。 ### 样例解释 对于第一个测试用例,Vlad上床后第一个响的闹钟是8:00的。 对于第二个测试用例,Vlad上床时有闹钟响起。 对于第三个测试用例,Vlad上床后第一个响的闹钟是第二天10:30的。

Output

题目大意:
Vlad和其他人一样,非常喜欢睡觉。他每天有n件事要做,每件事都有一个设定好的闹钟。他想知道在下一个闹钟响之前,他能睡多久。如果在他上床睡觉的时候有任何闹钟响起,那么他将睡0小时0分钟。

输入数据格式:
输入数据的第一行包含一个整数t(1≤t≤100),表示测试用例的数量。
每组测试用例的第一行包含三个整数n、H和M(1≤n≤10,0≤H<24,0≤M<60),分别表示闹钟的数量和Vlad上床睡觉的时间。
接下来n行,每行包含两个数字hi和mi(0≤hi<24,0≤mi<60),表示每个闹钟响的时间。两个或多个闹钟可以同时响起。描述时间的数字不包含前导零。

输出数据格式:
输出t行,每行都包含相应测试用例的答案。答案包括两个数字,分别表示Vlad将分别睡觉的小时数和分钟数。如果在他上床睡觉的时候有任何闹钟响起,答案将是0 0。

样例解释:
对于第一个测试用例,Vlad上床后第一个响的闹钟是8:00的,所以他能睡1小时47分钟。
对于第二个测试用例,Vlad上床时有闹钟响起,所以他只能睡0小时0分钟。
对于第三个测试用例,Vlad上床后第一个响的闹钟是第二天10:30的,所以他能睡10小时55分钟。题目大意: Vlad和其他人一样,非常喜欢睡觉。他每天有n件事要做,每件事都有一个设定好的闹钟。他想知道在下一个闹钟响之前,他能睡多久。如果在他上床睡觉的时候有任何闹钟响起,那么他将睡0小时0分钟。 输入数据格式: 输入数据的第一行包含一个整数t(1≤t≤100),表示测试用例的数量。 每组测试用例的第一行包含三个整数n、H和M(1≤n≤10,0≤H<24,0≤M<60),分别表示闹钟的数量和Vlad上床睡觉的时间。 接下来n行,每行包含两个数字hi和mi(0≤hi<24,0≤mi<60),表示每个闹钟响的时间。两个或多个闹钟可以同时响起。描述时间的数字不包含前导零。 输出数据格式: 输出t行,每行都包含相应测试用例的答案。答案包括两个数字,分别表示Vlad将分别睡觉的小时数和分钟数。如果在他上床睡觉的时候有任何闹钟响起,答案将是0 0。 样例解释: 对于第一个测试用例,Vlad上床后第一个响的闹钟是8:00的,所以他能睡1小时47分钟。 对于第二个测试用例,Vlad上床时有闹钟响起,所以他只能睡0小时0分钟。 对于第三个测试用例,Vlad上床后第一个响的闹钟是第二天10:30的,所以他能睡10小时55分钟。

加入题单

算法标签: