#K77092. Adjusting Overlapping Time Slots
Adjusting Overlapping Time Slots
Adjusting Overlapping Time Slots
You are given n booked time slots. Each time slot is represented by a starting time and an ending time (in minutes). Sometimes, these time slots may overlap with each other.
Your task is to adjust the time slots so that no two booked time slots overlap. If a time slot overlaps with the previous one, adjust it by setting its new start time to be equal to the end time of the previous slot while preserving its duration. Formally, if a slot given by \( [a, b] \) overlaps, it should be modified to \( [e, e + (b - a)] \) where \( e \) is the end time of the previous slot.
Note that you must first sort the time slots by their starting times before processing them.
inputFormat
The first line contains an integer n representing the number of time slots. Each of the following n lines contains two space-separated integers: the start and end times (in minutes) of a booked slot.
outputFormat
Output n lines, each containing two space-separated integers representing the adjusted time slot in order.
## sample3
10 20
30 40
50 60
10 20
30 40
50 60
</p>