| HPI 2024 Advanced |
|---|
| Finished |
Chad the chauffeur driver has $$$N$$$ trips scheduled for today. For each trip, we know that it starts at time $$$s_i$$$ and ends at time $$$e_i$$$. If a trip overlaps with another, the later trip is delayed and starts at the end of the earlier trip. A trip's start time can be the same as a previous trip's end time. Chad can also cancel at most $$$K$$$ trips.
To stop Chad from overworking himself, help him find the earliest time he can finish his trips.
Line 1: Two integers, $$$N$$$ and $$$K$$$ ($$$1 ≤ N ≤ 4000$$$, $$$1 ≤ K \lt N$$$).
Lines 2…$$$N$$$+1: Two integers, $$$s_i$$$ and $$$e_i$$$, representing the $$$i$$$th trip's starting time and ending time ($$$1 ≤ s_i \lt e_i ≤ 10^9$$$).
Line 1: One integer representing the earliest time Chad can finish his trips.
3 11 65 75 8
8
By canceling the last trip, Chad has to work only from $$$t$$$=1 to $$$t$$$=8.
| Name |
|---|


