#K2021. Optimized Backup Request Scheduling
Optimized Backup Request Scheduling
Optimized Backup Request Scheduling
You are given n backup requests. Each request is represented by a pair of integers \(t_i\) and \(d_i\), where \(t_i\) is the time when the request is made and \(d_i\) is the duration required to complete the backup.
The requests must be processed in order of increasing \(t_i\). The processing starts at time \(s_i\) for each request, where the start time is calculated using the following formula:
$$ s_1 = t_1 $$ $$ s_i = \max(t_i, s_{i-1}+d_{i-1}) \quad \text{for } i > 1$$
Your task is to determine the start time for each backup request after sorting them by \(t_i\). Output each request's original time \(t_i\) along with its computed start time \(s_i\). All output should be printed to standard output, each on a new line.
inputFormat
The input is read from standard input and is formatted as follows:
- The first line contains a single integer \(n\), the number of backup requests.
- The following \(n\) lines each contain two space-separated integers: \(t_i\) (the request time) and \(d_i\) (the duration of the request).
outputFormat
Output \(n\) lines to standard output. Each line should contain two space-separated integers: the request time \(t_i\) and the computed start time \(s_i\) for that request, in the order of increasing \(t_i\).
## sample1
5 2
5 5
</p>