Maximizing Productivity

시간 제한2초메모리 제한1024 MB

요약
농장별 폐쇄 시각과 베시의 고정 방문 시차가 주어질 때, 시각 S에 일어나 V개 이상 방문할 수 있는지 답한다.
난이도

보통10점 중 5점

유형
정렬, 이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

Farmer John has NN (1≤N≤2⋅1051 \leq N \leq 2 \cdot 10^5) farms, numbered from 11 to NN. It is known that FJ closes farm ii at time c_ic\_i. Bessie wakes up at time SS, and wants to maximize the productivity of her day by visiting as many farms as possible before they close. She plans to visit farm ii on time t_i+St\_i + S. Bessie must arrive at a farm strictly before Farmer John closes it to actually visit it.

Bessie has QQ (1≤Q≤2⋅105)(1 \leq Q \leq 2 \cdot 10^5) queries. For each query, she gives you two integers SS and VV. For each query, output whether Bessie can visit at least VV farms if she wakes up at time SS.

입력

The first line consists of NN and QQ.

The second line consists of c_1,c_2,c_3…c_Nc\_1, c\_2, c\_3 \dots c\_N (1≤c_i≤1061 \leq c\_i \leq 10^6).

The third line consists of t_1,t_2,t_3…t_Nt\_1, t\_2, t\_3 \dots t\_N (1≤t_i≤1061 \leq t\_i \leq 10^6).

The next QQ lines each consist of two integers VV (1≤V≤N1 \leq V \leq N) and SS (1≤S≤1061 \leq S \leq 10^6).

출력

For each of the QQ queries, output YES or NO on a new line.

예제1

  1. 예제 1

    입력
    5 5
    3 5 7 9 12
    4 2 3 3 8
    1 5
    1 6
    3 3
    4 2
    5 1
    
    예상 출력
    YES
    NO
    YES
    YES
    NO