A11697 | Mind the Gap
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $1$ minute.
He was asked to insert one takeoff in the schedule. The takeoff takes $1$ minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least $s$ minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
He was asked to insert one takeoff in the schedule. The takeoff takes $1$ minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least $s$ minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
输入格式
The first line of input contains two integers $n$ and $s$ ( $1 \le n \le 100$ , $1 \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 $n$ lines contains two integers $h$ and $m$ ( $0 \le h \le 23$ , $0 \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 $0$ $0$ ). These times are given in increasing order.
Each of next $n$ lines contains two integers $h$ and $m$ ( $0 \le h \le 23$ , $0 \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 $0$ $0$ ). These times are given in increasing order.
输出格式
Print two integers $h$ and $m$ — the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
输入输出样例
输入 #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 $24$ hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
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 $24$ hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted