CF967A.Mind the Gap

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 11 minute.

He was asked to insert one takeoff in the schedule. The takeoff takes 11 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least ss minutes from both sides.

Find the earliest time when Arkady can insert the takeoff.

最近,阿尔卡季在一家大型机场担任空中交通管制员。他负责一条通常仅用于飞机降落的跑道。因此,他手中有一份未来即将降落的飞机时刻表,每次降落持续 11 分钟。

他被要求在该时刻表中插入一次起飞。起飞本身耗时 11 分钟,但出于安全考虑,起飞与任何一次降落之间必须至少保留 ss 分钟的时间间隔(即起飞前后均需满足该条件)。

请找出阿尔卡季可以插入此次起飞的最早时间。

输入格式

The first line of input contains two integers nn and ss (1≤n≤1001 \le n \le 100, 1≤s≤601 \le s \le 60) — the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.

Each of next nn lines contains two integers hh and mm (0≤h≤230 \le h \le 23, 0≤m≤590 \le m \le 59) — the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 00 00). These times are given in increasing order.

输入的第一行包含两个整数 nn 和 ss(1≤n≤1001 \le n \le 100,1≤s≤601 \le s \le 60)—— 分别表示航班计划中降落的次数,以及降落与起飞之间允许的最短时间间隔(单位:分钟)。

接下来的 nn 行每行包含两个整数 hh 和 mm(0≤h≤230 \le h \le 23,0≤m≤590 \le m \le 59)—— 表示一架飞机将在当前时刻(即时间为 00 00)之后 hh 小时 mm 分钟降落。这些时间按升序给出。

输出格式

Print two integers hh and mm — the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.

输出两个整数 hh 和 mm —— 分别表示 Arkady 可以插入起飞时刻的最早时间点的小时和分钟。

输入输出样例

  • 输入#1

    6 60
    0 0
    1 20
    3 21
    5 0
    19 30
    23 40

    输出#1

    6 1
  • 输入#2

    16 50
    0 30
    1 20
    3 0
    4 30
    6 10
    7 50
    9 30
    11 10
    12 50
    14 30
    16 10
    17 50
    19 30
    21 10
    22 50
    23 59

    输出#2

    24 50
  • 输入#3

    3 17
    0 30
    1 0
    12 0

    输出#3

    0 0

说明/提示

In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.

In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 2424 hours to insert the takeoff.

In the third example Arkady can insert the takeoff even between the first landing.

在第一个例子中,请注意 1:20 到 3:21 之间的时间不足,因为每次降落和起飞各需一分钟。

在第二个例子中,时间表中没有空隙,因此 Arkady 只能在所有降落完成之后添加一次起飞。请注意,插入起飞可能需要等待超过 2424 小时。

在第三个例子中,Arkady 甚至可以在第一次降落之间插入起飞。

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

首页