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 は農場 $i$ を時刻 $c_i$ に閉めます。Bessie は時刻 $S$ に起き、閉まる前にできるだけ多くの農場を訪れて一日の生産性を最大にしたいと思っています。農場 $i$ を時刻 $t_i + S$ に訪れる予定です。実際に訪問するには、Farmer John が閉める時刻より厳密に前に到着しなければなりません。

Bessie は $Q$ 個のクエリ($1 \leq Q \leq 2 \cdot 10^5$)を持っています。各クエリでは2つの整数 $S$ と $V$ が与えられます。各クエリについて、時刻 $S$ に起きた場合に少なくとも $V$ 個の農場を訪問できるか出力してください。

入力

最初の行には $N$ と $Q$ が与えられます。

2行目には $c_1, c_2, c_3 \dots c_N$($1 \leq c_i \leq 10^6$)が与えられます。

3行目には $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

注記

最初のクエリで農場を訪れる時刻は $t = [9, 7, 8, 8, 13]$ なので、FJ が閉める前に間に合うのは農場 $4$ だけです。

2番目のクエリでは、どの農場にも間に合いません。

3番目のクエリでは、農場 $3, 4, 5$ に間に合います。

4番目と5番目のクエリでは、最初の農場以外のすべての農場に間に合います。

小課題

  • 入力 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.