#P16768. [GKS 2020 #F] Metal Harvest
[GKS 2020 #F] Metal Harvest
Problem Description
You are in charge of deploying robots to harvest Kickium from a nearby asteroid. Robots are not designed to work as a team, so only robot can harvest at any point of time. A single robot can be deployed for up to units of time in a row before it returns for calibration, regardless of how much time it spends on harvesting during that period. Harvesting can only be done during specific time intervals. These time intervals do not overlap. Given and the time intervals in which harvesting is allowed, what is the minimum number of robot deployments required to harvest at all possible times?
Input Format
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case gives two space separated integers and : the number of time intervals in which harvesting is allowed, and the maximum duration a robot can be deployed for before returning for calibration.
The next lines contain a pair of space separated integers and : the start time and the end time of the -th interval respectively. Please note that intervals don't include the time unit starting at the moment , so for example an interval with has duration of time units.
Output Format
For each test case, output one line containing Case #: `, where is the test case number (starting from ) and is the number of times robot deployment is needed so that for each interval there is one robot harvesting at that time.
2
3 5
1 5
10 11
8 9
3 2
1 2
3 5
13 14
Case #1: 2
Case #2: 3
Hint
In Sample Case #, we deploy the robot at time instant and it becomes available for the interval . However, it harvests only for the time range . After that we deploy the robot at and it becomes available for the time interval . This deployment covers both the remaining intervals and . There are multiple optimal strategies here. For example, we can deploy the nd robot at . It would then cover the range , thus harvesting for the intervals and .
In Sample Case #, we deploy the robot at time instant , and it becomes available for , but harvests for as is not part of any interval. After that we deploy the robot at for the time range in which the robot harvests for the interval . The rd deployment is done at time instant making the robot available for time range . However, it harvests only for the interval . Thus deployments are needed to cover all the intervals.
Limits
.
All are distinct.
For any two intervals and with , .
Test Set
.
.
.
Test Set
, in at most test cases.
, in the remaining test cases.
.
.