#P1752. 点菜
点菜
Description
There are people who come to a restaurant to order dishes. The restaurant has dishes in total, and each dish has two attributes: tastiness and price. These people come once every week, and each time each person will order at most one dish or none. Among these people, people are picky; they can only accept dishes with tastiness greater than or equal to a certain value. Another people are poor; they can only order dishes with price less than or equal to a certain value. Now please compute: what is the minimum number of weeks they need to come so that it is possible to have ordered all dishes at least once?
Input Format
- Line : four positive integers .
- Lines : each line contains two numbers, the tastiness and the price of a dish.
- Line : numbers, the lower bounds of acceptable tastiness for each of the picky people.
- Line : numbers, the upper bounds of acceptable price for each of the poor people.
Output Format
Output a single number: the minimum number of weeks needed. If it is impossible to have all dishes ordered at least once no matter how many weeks they come, output .
2 3 1 1
5 2
5 3
6 4
5
1
3
Hint
Constraints and Conventions:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号