#BS0000371. Lịch hạ cánh an toàn (A Careful Approach)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lịch hạ cánh an toàn (A Careful Approach)
A Careful Approach
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
At an airport, airplanes are awaiting landing. Airplane may land only within the closed interval from to minutes. The controller may choose the order and landing time of every airplane.
Let be the landing times in chronological order. The safety of a schedule is measured by the smallest time difference between consecutive landings:
Schedule all airplanes within their respective windows to maximize this value. Landing times may be real numbers.
Input
- The first line contains an integer , the number of airplanes.
- Line of the following lines contains integers , the beginning and end of airplane 's landing window in minutes.
Output
Print the optimal gap rounded to the nearest second (round exact half seconds up), in the format m:ss. Here m is the integer number of minutes without leading zeroes and ss is the remaining seconds, always written with two digits.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3
0 10
5 15
10 15
Output
7:30
Explanation
Land the airplanes at 0, 7.5 and 15 minutes respectively. Both gaps are 7.5 minutes. All times lie in [0,15], so the two gaps sum to at most 15 minutes. Neither schedule can have both gaps greater than 7.5 minutes.
Input
2
0 10
10 20
Output
20:00
Explanation
Land the first airplane at minute 0 and the second at minute 20. The gap equals the entire available span of 20 minutes.
Input
8
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
Output
0:09
Explanation
Eight airplanes create seven gaps over at most 60 seconds, so the smallest gap is at most seconds. Equal spacing from 0 to 60 seconds achieves the bound. Rounding approximately 8.5714 seconds gives 9 seconds.