문제
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 .
입력
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 ().
출력
For each of the queries, output YES or NO on a new line.
예제 입력 1
5 5
3 5 7 9 12
4 2 3 3 8
1 5
1 6
3 3
4 2
5 1
예제 출력 1
YES
NO
YES
YES
NO
점수
Inputs 2-4: Inputs 5-9: Inputs 10-17: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인