QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20862. Massimizzare la produttività

Statistics

Farmer John ha $N$ fattorie ($1 \leq N \leq 2 \cdot 10^5$), numerate da $1$ a $N$. Si sa che FJ chiude la fattoria $i$ all’istante $c_i$. Bessie si sveglia all’istante $S$ e vuole rendere la sua giornata il più produttiva possibile visitando quante più fattorie può prima che chiudano. Ha intenzione di visitare la fattoria $i$ all’istante $t_i + S$. Per poterla visitare, Bessie deve arrivare strettamente prima che Farmer John la chiuda.

Bessie ha $Q$ richieste ($1 \leq Q \leq 2 \cdot 10^5$). Per ognuna fornisce due interi $S$ e $V$. Per ogni richiesta, indica se Bessie può visitare almeno $V$ fattorie svegliandosi all’istante $S$.

Input

La prima riga contiene $N$ e $Q$.

La seconda riga contiene $c_1, c_2, c_3 \dots c_N$ ($1 \leq c_i \leq 10^6$).

La terza riga contiene $t_1, t_2, t_3 \dots t_N$ ($1 \leq t_i \leq 10^6$).

Ognuna delle successive $Q$ righe contiene due interi $V$ ($1 \leq V \leq N$) e $S$ ($1 \leq S \leq 10^6$).

Output

Per ognuna delle $Q$ richieste, stampa YES o NO su una nuova riga.

Esempi

Input 1

5 5
3 5 7 9 12
4 2 3 3 8
1 5
1 6
3 3
4 2
5 1

Output 1

YES
NO
YES
YES
NO

Note

Per la prima richiesta, Bessie visiterà le fattorie agli istanti $t = [9, 7, 8, 8, 13]$, quindi riuscirà a visitare in tempo solo la fattoria $4$, prima che FJ la chiuda.

Per la seconda richiesta, Bessie non riuscirà a visitare alcuna fattoria in tempo.

Per la terza richiesta, Bessie visiterà le fattorie $3, 4, 5$ in tempo.

Per la quarta e la quinta richiesta, Bessie riuscirà a visitare in tempo tutte le fattorie tranne la prima.

Sottoproblemi

  • Input 2–4: $N,Q\le 10^3$
  • Input 5–9: $c_i, t_i \le 20$
  • Input 10–17: nessun vincolo aggiuntivo.

Autore del problema: Chongtian Ma

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.