A - Comparing Test Scores Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

青木君のクラスでは先日、数学のテストが行われました。クラスには N 人の生徒がおり、それぞれ 1 から N までの出席番号が付けられています。生徒 i (1 \leq i \leq N) のテストの点数は S_i 点です。

青木君は先生から頼まれて、生徒たちの成績を整理しています。青木君は Q 個の質問に答える必要があります。i 番目の質問では、出席番号 a_i の生徒の点数が出席番号 b_i の生徒の点数より厳密に高いかどうかを判定します。ここで「厳密に高い」とは、等しい場合を含まず、S_{a_i} > S_{b_i} が成り立つことを意味します。なお、a_i = b_i、すなわち同じ生徒同士の比較が行われる場合もあります。

各質問に対して、S_{a_i} > S_{b_i} ならば Yes を、そうでなければ(すなわち S_{a_i} \leq S_{b_i} ならば) No を出力してください。

制約

  • 1 \leq N \leq 10^5
  • 1 \leq Q \leq 10^5
  • 0 \leq S_i \leq 100 (1 \leq i \leq N)
  • 1 \leq a_i \leq N (1 \leq i \leq Q)
  • 1 \leq b_i \leq N (1 \leq i \leq Q)
  • a_i = b_i である場合もある
  • 入力はすべて整数

入力

N Q
S_1 S_2 \ldots S_N
a_1 b_1
a_2 b_2
\vdots
a_Q b_Q
  • 1 行目には、生徒の人数を表す整数 N と、質問の個数を表す整数 Q が、スペース区切りで与えられる。
  • 2 行目には、各生徒のテストの点数を表す N 個の整数 S_1, S_2, \ldots, S_N が、スペース区切りで与えられる。
  • 続く Q 行のうち i 行目 (1 \leq i \leq Q) には、i 番目の質問で比較する 2 人の生徒の出席番号を表す整数 a_ib_i が、スペース区切りで与えられる。

出力

Q 行にわたって出力してください。i 行目 (1 \leq i \leq Q) には、i 番目の質問に対する答えとして、S_{a_i} > S_{b_i} ならば Yes を、そうでなければ No を出力してください。


入力例 1

3 4
80 65 80
1 2
2 1
1 3
3 1

出力例 1

Yes
No
No
No

入力例 2

5 6
72 85 60 85 90
5 2
2 4
1 3
4 2
3 5
2 1

出力例 2

Yes
No
Yes
No
No
Yes

入力例 3

10 8
45 78 92 65 100 38 72 0 55 100
5 10
10 5
6 8
8 6
3 1
1 2
4 7
9 4

出力例 3

No
No
Yes
No
Yes
No
No
No

Score : 200 pts

Problem Statement

A math test was recently held in Aoki's class. There are N students in the class, each assigned a student number from 1 to N. The test score of student i (1 \leq i \leq N) is S_i points.

Aoki has been asked by the teacher to organize the students' grades. Aoki needs to answer Q questions. For the i-th question, he determines whether the score of the student with student number a_i is strictly higher than the score of the student with student number b_i. Here, "strictly higher" means that equality is not included, i.e., S_{a_i} > S_{b_i} holds. Note that a_i = b_i is possible, meaning a comparison of the same student with themselves may occur.

For each question, output Yes if S_{a_i} > S_{b_i}, and No otherwise (i.e., if S_{a_i} \leq S_{b_i}).

Constraints

  • 1 \leq N \leq 10^5
  • 1 \leq Q \leq 10^5
  • 0 \leq S_i \leq 100 (1 \leq i \leq N)
  • 1 \leq a_i \leq N (1 \leq i \leq Q)
  • 1 \leq b_i \leq N (1 \leq i \leq Q)
  • It is possible that a_i = b_i
  • All input values are integers

Input

N Q
S_1 S_2 \ldots S_N
a_1 b_1
a_2 b_2
\vdots
a_Q b_Q
  • The first line contains an integer N representing the number of students and an integer Q representing the number of questions, separated by a space.
  • The second line contains N integers S_1, S_2, \ldots, S_N representing the test scores of each student, separated by spaces.
  • In the following Q lines, the i-th line (1 \leq i \leq Q) contains integers a_i and b_i representing the student numbers of the two students to compare in the i-th question, separated by a space.

Output

Output Q lines. On the i-th line (1 \leq i \leq Q), output Yes if S_{a_i} > S_{b_i}, and No otherwise, as the answer to the i-th question.


Sample Input 1

3 4
80 65 80
1 2
2 1
1 3
3 1

Sample Output 1

Yes
No
No
No

Sample Input 2

5 6
72 85 60 85 90
5 2
2 4
1 3
4 2
3 5
2 1

Sample Output 2

Yes
No
Yes
No
No
Yes

Sample Input 3

10 8
45 78 92 65 100 38 72 0 55 100
5 10
10 5
6 8
8 6
3 1
1 2
4 7
9 4

Sample Output 3

No
No
Yes
No
Yes
No
No
No