#P2684. 搞清洁
搞清洁
Description
FJ plans to assign his cows to do cleaning. He divides the day into time slots. He wants every time slot to have a cow cleaning, while using as few cows as possible.
Input Format
The first line contains two integers and .
The next lines each contain two integers, representing the time interval during which the -th cow can work (inclusive).
Output Format
Output the minimum number of cows needed so that every time slot has a cow working. If it is impossible, output -1.
3 10
1 7
3 6
8 10
2
Hint
Sample explanation:
There are cows. The -st can work during , that is, starts at time and ends at time (time is also covered). The -nd works during , and the -rd during . Then only the -st and the -rd cows are needed to ensure every time slot is covered.
Translated by ChatGPT 5
京公网安备 11011102002149号