QOJ.ac

QOJ

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

#20862. 最大化效率

Statistics

Farmer John 有 $N$ 個農場($1 \leq N \leq 2 \cdot 10^5$),編號從 $1$ 到 $N$。已知 FJ 在時刻 $c_i$ 關閉農場 $i$。Bessie 在時刻 $S$ 醒來,想在農場關閉前盡可能多地參觀農場,讓一天過得最有效率。她計畫在時刻 $t_i + S$ 參觀農場 $i$。Bessie 必須嚴格早於 Farmer John 關閉農場的時刻到達,才能真正參觀該農場。

Bessie 有 $Q$ 個詢問($1 \leq Q \leq 2 \cdot 10^5$)。每個詢問給出兩個整數 $S$ 和 $V$。對每個詢問,輸出 Bessie 在時刻 $S$ 醒來時能否參觀至少 $V$ 個農場。

輸入格式

第一行包含 $N$ 和 $Q$。

第二行包含 $c_1, c_2, c_3 \dots c_N$($1 \leq c_i \leq 10^6$)。

第三行包含 $t_1, t_2, t_3 \dots t_N$($1 \leq t_i \leq 10^6$)。

接下來的 $Q$ 行各包含兩個整數 $V$($1 \leq V \leq N$)和 $S$($1 \leq S \leq 10^6$)。

輸出格式

對於 $Q$ 個詢問中的每一個,在新的一行輸出 YES 或 NO。

範例

輸入格式 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

說明

對第一個詢問,Bessie 參觀各農場的時刻為 $t = [9, 7, 8, 8, 13]$,因此只有農場 $4$ 能在 FJ 關閉前及時參觀。

對第二個詢問,Bessie 無法及時參觀任何農場。

對第三個詢問,Bessie 能及時參觀農場 $3, 4, 5$。

對第四與第五個詢問,Bessie 能及時參觀除了第一個農場以外的所有農場。

子任務

  • 輸入 2–4:$N,Q\le 10^3$
  • 輸入 5–9:$c_i, t_i \le 20$
  • 輸入 10–17:沒有額外限制。

題目作者: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.