#P10762. [BalticOI 2024] Fire
[BalticOI 2024] Fire
Background
Translated from BalticOI 2024 Day2 T1.
Problem Description
We divide one day into time units. There are people, and person is willing to work during . If , it means this person is willing to work until time on the next day. Each person’s maximum continuous working time does not exceed one full day.
You need to arrange some people to work so that their working time can cover the whole day. Find the number of people needed.
Input Format
The first line contains two integers .
The next lines each contain a pair .
Output Format
Output one integer, the minimum number of people to arrange. If it is impossible to arrange people so that the whole day is covered, output .
4 100
10 30
30 70
20 40
60 20
3
1 100
30 40
-1
Hint
For the first sample, choose .
For the second sample, there is clearly no solution.
| Subtask ID | Special Property | Score |
|---|---|---|
| Guaranteed or | ||
| Guaranteed that everyone has the same working time interval | ||
| No special property |
For all testdata, , , , .
Translated by ChatGPT 5