#5019. Problem 3. Maximizing Productivity
Problem 3. Maximizing Productivity
Problem 3. Maximizing Productivity
USACO 2024 February Contest, Bronze
Farmer John has () farms, numbered from to . It is known that FJ closes farm at time . Bessie wakes up at time , and wants to maximize the productivity of her day by visiting as many farms as possible before they close. She plans to visit farm on time . Bessie must arrive at a farm strictly before Farmer John closes it to actually visit it.
Bessie has queries. For each query, she gives you two integers and . For each query, output whether Bessie can visit at least farms if she wakes up at time .
INPUT FORMAT (input arrives from the terminal / stdin):
The first line consists of and .
The second line consists of ().
The third line consists of ().
The next lines each consist of two integers () and ().
OUTPUT FORMAT (print output to the terminal / stdout):
For each of the queries, output YES or NO on a new line.
SAMPLE INPUT:
5 5 3 5 7 9 12 4 2 3 3 8 1 5 1 6 3 3 4 2 5 1
SAMPLE OUTPUT:
YES NO YES YES NO
For the first query, Bessie will visit the farms at time , so she will only get to visit farm on time before FJ closes the farm.
For the second query, Bessie will not be able to visit any of the farms on time.
For the third query, Bessie will visit farms on time.
For the fourth and fifth queries, Bessie will be able to visit all but the first farm on time.
SCORING: Inputs 2-4: Inputs 5-9: Inputs 10-17: No additional constraints.
Problem credits: Chongtian Ma