Hide

Problem D
Cloud Conundrum

Languages en sv
/problems/epc17.cloudconundrum/file/statement/en/img-0001.jpg
Pixabay, cc0
There’s money to be made in the clouds, or at least amongst the server rooms. No surprise then that Ericsson is invested in cloud computing as well. The question is, how much money is there to be made?

Grossly simplified one might say “more work, more money". Now that we’ve started simplifying we might as well continue to simplify and say that each server in the cloud can work with precisely one assignement at a time. Of course, the whole point of a cloud is for clients to place workorders that they want computed by the cloud.

A workorder consists of a starting time $s_ i$
after a original time $t_0=0$ representing when
the assignment will be uploaded and a integer $l_ i$
representing the length of the assignement. A number of clients have now placed workorders but no one thought to double check if it’s possible to compute every workorder (clouds are huge, it shouldn’t be a problem). The clients of course don’t want to change details of their jobs which means that if there isn’t a server available to start working immediately according to schedule the customer will retract that workorder and find someone else to complete it. At the same time it’s inefficient to have more servers working than neccessary. Therefore it was decided that as long as it’s possible to complete a certain number of workorders the number of used servers should be minimized and that this would make the most money.

Now, your help is needed to calculate the minimum number of servers needed to serve $k$ assignments given that the servers can start with the next workorder immediately after the previous one is finished. Meaning that if an assignment is completed at a time $t_{end}$ the next job can start at $t_{next} \geq t_{end}$.

Input

First, one row containing the two integers $n$ and $k$, the total number of workorders and the minimum number of workorders that need to be completed. The following $n$ rows contain two integers $s_ i$ and $l_ i$ representing the starting time and length for workorder $i$

$0 \leq k \leq n \leq 50000$
$0 \leq s_ i \leq 10^9$ $1 \leq l_ i \leq 10^9$

Output

Output one integer, the minimum number of servers needed to complete the minimum number of workorders.

Sample Input 1 Sample Output 1
7 5
10 5
2 8
6 13
8 2
5 5
1 6
2 10
3

Please log in to submit a solution to this problem

Log in