CF1714A.Everyone Loves to Sleep

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vlad, like everyone else, loves to sleep very much.

Every day Vlad has to do nn things, each at a certain time. For each of these things, he has an alarm clock set, the ii-th of them is triggered on hih_i hours mim_i minutes every day (0≤hi<24,0≤mi<600 \le h_i \lt 24, 0 \le m_i \lt 60). Vlad uses the 2424-hour time format, so after h=12,m=59h=12, m=59 comes h=13,m=0h=13, m=0 and after h=23,m=59h=23, m=59 comes h=0,m=0h=0, m=0.

This time Vlad went to bed at HH hours MM minutes (0≤H<24,0≤M<600 \le H \lt 24, 0 \le M \lt 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 00.

弗拉德和所有人一样,非常喜欢睡觉。

每天弗拉德都要做 nn 件事,每件事都在特定的时间进行。对于每件事,他都设定了一个闹钟,其中第 ii 个闹钟每天在 hih_i 时 mim_i 分响起(0≤hi<24, 0≤mi<600 \le h_i \lt 24,\ 0 \le m_i \lt 60)。弗拉德采用 24 小时制时间格式,因此在 h=12, m=59h=12,\,m=59 之后是 h=13, m=0h=13,\,m=0,而在 h=23, m=59h=23,\,m=59 之后是 h=0, m=0h=0,\,m=0。

这次弗拉德在 HH 时 MM 分(0≤H<24, 0≤M<600 \le H \lt 24,\ 0 \le M \lt 60)上床睡觉,他请你回答:他能睡多久,直到下一个闹钟响起。

如果在他上床睡觉的同一时刻有任何一个闹钟响起,则他的睡眠时长为 00。

输入格式

The first line of input data contains an integer tt (1≤t≤1001 \le t \le 100) — the number of test cases in the test.

The first line of the case contains three integers nn, HH and MM (1≤n≤10,0≤H<24,0≤M<601 \le n \le 10, 0 \le H \lt 24, 0 \le M \lt 60) — the number of alarms and the time Vlad went to bed.

The following nn lines contain two numbers each hih_i and mim_i (0≤hi<24,0≤mi<600 \le h_i \lt 24, 0 \le m_i \lt 60) — the time of the ii alarm. It is acceptable that two or more alarms will trigger at the same time.

Numbers describing time do not contain leading zeros.

输入数据的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示测试用例的数量。

每个测试用例的第一行包含三个整数 nn、HH 和 MM(1≤n≤101 \le n \le 10,0≤H<240 \le H \lt 24,0≤M<600 \le M \lt 60),分别表示闹钟的数量以及弗拉德入睡的时间。

接下来的 nn 行每行包含两个数字 hih_i 和 mim_i(0≤hi<240 \le h_i \lt 24,0≤mi<600 \le m_i \lt 60),表示第 ii 个闹钟的触发时间。允许两个或更多闹钟在同一时刻触发。

描述时间的数字不包含前导零。

输出格式

Output tt 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.

输出 tt 行,每行包含对应测试用例的答案。作为答案,输出两个数字——分别为弗拉德将要睡眠的小时数和分钟数。如果任意一个闹钟在他上床睡觉的时刻响起,则答案为 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

输入解题思路,AI测评打分。不知道怎么写?

首页