Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
高橋君と青木君は、同じ講義のノートをそれぞれ取っていました。しかし、二人とも途中で読み取れなかった部分があり、ノートには一部空欄があります。
講義で板書された内容は英小文字のみからなる N 文字の文字列でした。高橋君のノートを文字列 S、青木君のノートを文字列 T とします。S, T はいずれも N 文字からなり、読み取れなかった箇所は ? として記録されています。それ以外の箇所には英小文字が記録されていますが、書き写し間違いにより元の板書と異なる文字が記録されている可能性があります。
二人は互いのノートを見比べて、元の板書の復元を試みます。二人が一致して書き取れた文字は正しいと信じることにして、各位置 i(1 \leq i \leq N)について、S の i 文字目と T の i 文字目を比較し、以下のルールで復元後の i 文字目を決定します。
- 両方とも同じ英小文字である場合、その文字を採用します。
- 一方が
?でもう一方が英小文字である場合、その英小文字を採用します。 - 両方とも
?である場合、復元できないため?のまま残します。 - 両方とも英小文字であるが互いに異なる場合、少なくとも一方のノートに書き写し間違いがあり正しい文字を判定できないため、矛盾を表す
!とします。
すべての位置について復元を行った結果の文字列を出力してください。また、復元結果に矛盾(!)が 1 箇所でも含まれるかどうかを判定し、含まれる場合は Yes を、含まれない場合は No を出力してください。
制約
- 1 \leq N \leq 5 \times 10^5
- N は整数である。
- S は英小文字および
?からなる長さ N の文字列である。 - T は英小文字および
?からなる長さ N の文字列である。
入力
N S T
- 1 行目には、文字列の長さを表す整数 N が与えられる。
- 2 行目には、高橋君のノートを表す長さ N の文字列 S が与えられる。
- 3 行目には、青木君のノートを表す長さ N の文字列 T が与えられる。
出力
2 行で出力せよ。
- 1 行目には、復元した長さ N の文字列を出力せよ。各位置の文字は問題文中のルールに従って決定される。
- 2 行目には、復元結果に
!が 1 箇所以上含まれる場合(矛盾がある場合)はYesを、含まれない場合はNoを出力せよ。
入力例 1
5 ab?de a?cd?
出力例 1
abcde No
入力例 2
6 abc?ef axc?yf
出力例 2
a!c?!f Yes
入力例 3
15 he??o?wor?d?abc ?ell??world?axc
出力例 3
hello?world?a!c Yes
入力例 4
40 ab?dab?dab?dab?dab?dab?dab?dab?dab?dab?d a?cda?cda?cda?cda?cda?cda?cda?cda?cda?cd
出力例 4
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd No
入力例 5
1 ? ?
出力例 5
? No
Score : 233 pts
Problem Statement
Takahashi and Aoki each took notes during the same lecture. However, both of them had parts they couldn't read, so their notes contain some blanks.
The content written on the blackboard during the lecture was a string of N characters consisting only of lowercase English letters. Let string S represent Takahashi's notes and string T represent Aoki's notes. Both S and T consist of N characters, where parts that couldn't be read are recorded as ?. All other parts are recorded as lowercase English letters, but due to copying errors, some characters may differ from the original blackboard content.
The two compare each other's notes and attempt to reconstruct the original blackboard content. They decide to trust characters that both of them wrote down identically. For each position i (1 \leq i \leq N), they compare the i-th character of S with the i-th character of T and determine the i-th character of the reconstruction according to the following rules:
- If both are the same lowercase English letter, adopt that letter.
- If one is
?and the other is a lowercase English letter, adopt that lowercase English letter. - If both are
?, the character cannot be reconstructed, so it remains?. - If both are lowercase English letters but differ from each other, at least one of the notes contains a copying error and the correct character cannot be determined, so it becomes
!to represent a contradiction.
Output the resulting string after performing the reconstruction for all positions. Also, determine whether the reconstruction result contains at least one contradiction (!), and output Yes if it does, or No if it does not.
Constraints
- 1 \leq N \leq 5 \times 10^5
- N is an integer.
- S is a string of length N consisting of lowercase English letters and
?. - T is a string of length N consisting of lowercase English letters and
?.
Input
N S T
- The first line contains an integer N representing the length of the strings.
- The second line contains the string S of length N representing Takahashi's notes.
- The third line contains the string T of length N representing Aoki's notes.
Output
Output in 2 lines.
- On the first line, output the reconstructed string of length N. The character at each position is determined according to the rules described in the problem statement.
- On the second line, output
Yesif the reconstruction result contains at least one!(i.e., there is a contradiction), orNootherwise.
Sample Input 1
5 ab?de a?cd?
Sample Output 1
abcde No
Sample Input 2
6 abc?ef axc?yf
Sample Output 2
a!c?!f Yes
Sample Input 3
15 he??o?wor?d?abc ?ell??world?axc
Sample Output 3
hello?world?a!c Yes
Sample Input 4
40 ab?dab?dab?dab?dab?dab?dab?dab?dab?dab?d a?cda?cda?cda?cda?cda?cda?cda?cda?cda?cd
Sample Output 4
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd No
Sample Input 5
1 ? ?
Sample Output 5
? No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 333 点
問題文
高橋君は、庭に一列に並んだ N 個の花壇を管理しています。花壇には左から順に 1 から N の番号がついており、花壇 i には「美しさ」A_i が定められています。
高橋君は、N 個の花壇それぞれについて、手入れするかしないかを選びます。ただし、手入れする花壇の選び方は以下の条件を満たさなければなりません。
- ある整数 l(1 \leq l \leq N - K + 1)が存在して、花壇 l, l+1, \ldots, l+K-1 がすべて手入れする花壇に含まれる。
すなわち、連続する K 個の花壇がすべて手入れされるような区間が少なくとも 1 つ存在しなければなりません。この条件さえ満たしていれば、それ以外の花壇については手入れしてもしなくても構いません。
手入れする花壇として選んだものの美しさの合計としてありえる最大値を求めてください。
制約
- 1 \leq K \leq N \leq 5 \times 10^5
- -10^9 \leq A_i \leq 10^9
- 入力はすべて整数
入力
N K A_1 A_2 \cdots A_N
- 1 行目には、花壇の総数 N と、連続して手入れしなければならない花壇の個数 K が、スペース区切りで与えられる。
- 2 行目には、各花壇の美しさ A_1, A_2, \ldots, A_N が、スペース区切りで与えられる。
出力
条件を満たすように手入れする花壇を選んだとき、美しさの合計の最大値を一行に出力してください。
入力例 1
5 2 3 -5 4 2 -1
出力例 1
9
入力例 2
4 3 -2 -7 -1 -3
出力例 2
-10
入力例 3
10 4 5 -2 3 -1 6 -7 4 2 -3 8
出力例 3
25
入力例 4
20 6 4 -5 7 0 -2 9 -8 3 1 -4 6 -1 5 -7 2 8 -3 4 -6 10
出力例 4
54
入力例 5
1 1 -1000000000
出力例 5
-1000000000
Score : 333 pts
Problem Statement
Takahashi manages N flower beds arranged in a row in his garden. The flower beds are numbered 1 to N from left to right, and flower bed i has a defined "beauty" value A_i.
For each of the N flower beds, Takahashi chooses whether or not to maintain it. However, the selection of flower beds to maintain must satisfy the following condition:
- There exists an integer l (1 \leq l \leq N - K + 1) such that flower beds l, l+1, \ldots, l+K-1 are all included in the maintained flower beds.
In other words, there must exist at least one interval where K consecutive flower beds are all maintained. As long as this condition is satisfied, any other flower bed may or may not be maintained.
Find the maximum possible sum of beauty values of the flower beds chosen for maintenance.
Constraints
- 1 \leq K \leq N \leq 5 \times 10^5
- -10^9 \leq A_i \leq 10^9
- All inputs are integers
Input
N K A_1 A_2 \cdots A_N
- The first line contains the total number of flower beds N and the number of consecutive flower beds that must be maintained K, separated by a space.
- The second line contains the beauty values of each flower bed A_1, A_2, \ldots, A_N, separated by spaces.
Output
Print on one line the maximum sum of beauty values when choosing flower beds to maintain while satisfying the condition.
Sample Input 1
5 2 3 -5 4 2 -1
Sample Output 1
9
Sample Input 2
4 3 -2 -7 -1 -3
Sample Output 2
-10
Sample Input 3
10 4 5 -2 3 -1 6 -7 4 2 -3 8
Sample Output 3
25
Sample Input 4
20 6 4 -5 7 0 -2 9 -8 3 1 -4 6 -1 5 -7 2 8 -3 4 -6 10
Sample Output 4
54
Sample Input 5
1 1 -1000000000
Sample Output 5
-1000000000
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 366 点
問題文
高橋君は N 台のスマートフォンを管理しています。スマートフォンには 1 から N までの番号が付けられており、スマートフォン i (1 \leq i \leq N) の初期バッテリー残量は S_i です。
これらのスマートフォンは、アプリの通知を受け取ることでバッテリーを消費します。ある日、Q 回の通知イベントが 1 番目から Q 番目まで順番に発生しました。j 番目 (1 \leq j \leq Q) の通知イベントでは、番号が L_j 以上 R_j 以下であるすべてのスマートフォンのバッテリー残量がそれぞれ 1 減少します。ただし、バッテリー残量が 0 のスマートフォンは 0 のまま変化しません。すなわち、通知イベントの対象となるスマートフォンのバッテリー残量を b とすると、b は \max(b - 1,\ 0) に変化します。
すべての通知イベントが終了した後の、各スマートフォンの最終的なバッテリー残量を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq Q \leq 2 \times 10^5
- 0 \leq S_i \leq 10^9 (1 \leq i \leq N)
- 1 \leq L_j \leq R_j \leq N (1 \leq j \leq Q)
- 入力はすべて整数
入力
N Q S_1 S_2 \ldots S_N L_1 R_1 L_2 R_2 \vdots L_Q R_Q
- 1 行目には、スマートフォンの台数を表す整数 N と、通知イベントの回数を表す整数 Q が、スペース区切りで与えられる。
- 2 行目には、各スマートフォンの初期バッテリー残量を表す整数 S_1, S_2, \ldots, S_N が、スペース区切りで与えられる。
- 続く Q 行のうち j 行目 (1 \leq j \leq Q) には、j 番目の通知イベントの対象となるスマートフォンの番号の範囲を表す整数 L_j と R_j が、スペース区切りで与えられる。
出力
すべての通知イベント終了後の各スマートフォンのバッテリー残量を、スマートフォン 1 から N の順にスペース区切りで 1 行で出力せよ。末尾に改行を入れること。
入力例 1
5 3 10 5 3 8 2 1 3 2 4 3 5
出力例 1
9 3 0 6 1
入力例 2
4 5 3 1 4 2 1 2 1 2 2 3 3 4 1 4
出力例 2
0 0 1 0
入力例 3
10 8 100 0 5 20 3 15 8 0 12 7 1 5 3 7 2 6 5 10 1 10 6 8 4 4 1 3
出力例 3
97 0 0 15 0 10 4 0 10 5
Score : 366 pts
Problem Statement
Takahashi manages N smartphones. The smartphones are numbered from 1 to N, and the initial battery level of smartphone i (1 \leq i \leq N) is S_i.
These smartphones consume battery by receiving app notifications. One day, Q notification events occurred in order from the 1-st to the Q-th. In the j-th (1 \leq j \leq Q) notification event, the battery level of every smartphone whose number is between L_j and R_j inclusive decreases by 1. However, a smartphone whose battery level is 0 remains at 0. That is, if the battery level of a smartphone targeted by the notification event is b, then b changes to \max(b - 1,\ 0).
Find the final battery level of each smartphone after all notification events have finished.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq Q \leq 2 \times 10^5
- 0 \leq S_i \leq 10^9 (1 \leq i \leq N)
- 1 \leq L_j \leq R_j \leq N (1 \leq j \leq Q)
- All inputs are integers
Input
N Q S_1 S_2 \ldots S_N L_1 R_1 L_2 R_2 \vdots L_Q R_Q
- The first line contains an integer N representing the number of smartphones and an integer Q representing the number of notification events, separated by a space.
- The second line contains integers S_1, S_2, \ldots, S_N representing the initial battery levels of each smartphone, separated by spaces.
- In the following Q lines, the j-th line (1 \leq j \leq Q) contains integers L_j and R_j representing the range of smartphone numbers targeted by the j-th notification event, separated by a space.
Output
Print the battery levels of all smartphones after all notification events have finished, in order from smartphone 1 to N, separated by spaces, on a single line. Include a newline at the end.
Sample Input 1
5 3 10 5 3 8 2 1 3 2 4 3 5
Sample Output 1
9 3 0 6 1
Sample Input 2
4 5 3 1 4 2 1 2 1 2 2 3 3 4 1 4
Sample Output 2
0 0 1 0
Sample Input 3
10 8 100 0 5 20 3 15 8 0 12 7 1 5 3 7 2 6 5 10 1 10 6 8 4 4 1 3
Sample Output 3
97 0 0 15 0 10 4 0 10 5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
高橋君は山岳縦走が趣味の登山家です。ある山岳地帯には N 個の山小屋があり、山小屋には 1 から N までの番号がついています。山小屋同士は M 本の一方通行の登山道で結ばれています。j 本目の登山道は山小屋 U_j から山小屋 V_j へ一方通行で通行でき、逆方向には通行できません。
各山小屋 i には標高 P_i が設定されています。すべての山小屋の標高は互いに異なります。
高橋君は山小屋 1 から出発し、登山道を辿りながら縦走を行います。山小屋の列 v_1, v_2, \ldots, v_k(k \geq 1)が以下の条件をすべて満たすとき、これを「よい縦走」と呼びます。
- v_1 = 1 である。すなわち、山小屋 1 から出発する。
- すべての i(1 \leq i \leq k-1)について、山小屋 v_i から山小屋 v_{i+1} への一方通行の登山道が存在する。
- すべての i(1 \leq i \leq k-1)について P_{v_i} < P_{v_{i+1}} が成り立つ。すなわち、連続して訪れる山小屋の標高が 狭義単調増加 になっている。
「よい縦走」は任意の山小屋で終了してよく、終点に関する制約はありません。また、山小屋 1 のみにいて登山道を 1 本も辿らない場合(k = 1)も「よい縦走」に該当します。したがって、答えは必ず 1 以上です。
高橋君はできるだけ多くの山小屋を巡りたいと考えています。「よい縦走」において訪れる山小屋の数 k の最大値を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 0 \leq M \leq 2 \times 10^5
- 1 \leq P_i \leq 10^9 (1 \leq i \leq N)
- P_i はすべて異なる。
- 1 \leq U_j, V_j \leq N (1 \leq j \leq M)
- U_j \neq V_j (1 \leq j \leq M)
- 同じ組 (U_j, V_j) が複数回与えられることはない。
- 入力はすべて整数である。
入力
N M P_1 P_2 \cdots P_N U_1 V_1 U_2 V_2 \vdots U_M V_M
- 1 行目には、山小屋の数を表す整数 N と、登山道の数を表す整数 M が、スペース区切りで与えられる。
- 2 行目には、各山小屋の標高を表す整数 P_1, P_2, \ldots, P_N が、スペース区切りで与えられる。P_i は山小屋 i の標高を表す。
- 続く M 行にわたり、登山道の情報が与えられる。そのうち j 行目(入力全体の 2 + j 行目)には、j 本目の登山道の始点 U_j と終点 V_j がスペース区切りで与えられる。これは山小屋 U_j から山小屋 V_j への一方通行の登山道が存在することを意味する。
出力
「よい縦走」において訪れることができる山小屋の数の最大値を 1 行で出力せよ。
入力例 1
5 4 10 20 30 40 5 1 2 2 3 3 4 1 3
出力例 1
4
入力例 2
4 4 100 50 30 200 1 2 1 3 2 4 3 4
出力例 2
1
入力例 3
8 9 15 30 10 45 25 50 35 60 1 2 1 5 2 4 5 7 7 4 4 6 6 8 1 3 3 5
出力例 3
6
入力例 4
15 20 5 50 10 45 15 40 20 35 25 30 55 60 65 70 75 1 3 3 5 5 7 7 9 9 10 10 11 11 12 12 13 13 14 14 15 1 2 2 4 4 6 6 8 1 5 3 7 5 9 9 11 7 10 2 6
出力例 4
11
入力例 5
1 0 1000000000
出力例 5
1
Score : 400 pts
Problem Statement
Takahashi is a mountaineer whose hobby is mountain traversing. In a certain mountainous region, there are N mountain huts, numbered from 1 to N. The mountain huts are connected by M one-way mountain trails. The j-th trail allows one-way passage from mountain hut U_j to mountain hut V_j, and cannot be traversed in the reverse direction.
Each mountain hut i has an elevation P_i. All mountain huts have distinct elevations.
Takahashi starts from mountain hut 1 and performs a traverse by following mountain trails. A sequence of mountain huts v_1, v_2, \ldots, v_k (k \geq 1) is called a "good traverse" if it satisfies all of the following conditions:
- v_1 = 1. That is, the traverse starts from mountain hut 1.
- For all i (1 \leq i \leq k-1), there exists a one-way mountain trail from mountain hut v_i to mountain hut v_{i+1}.
- For all i (1 \leq i \leq k-1), P_{v_i} < P_{v_{i+1}} holds. That is, the elevations of consecutively visited mountain huts are strictly monotonically increasing.
A "good traverse" may end at any mountain hut; there is no constraint on the endpoint. Additionally, staying only at mountain hut 1 without following any trail (k = 1) also counts as a "good traverse". Therefore, the answer is always at least 1.
Takahashi wants to visit as many mountain huts as possible. Find the maximum value of k, the number of mountain huts visited in a "good traverse".
Constraints
- 1 \leq N \leq 2 \times 10^5
- 0 \leq M \leq 2 \times 10^5
- 1 \leq P_i \leq 10^9 (1 \leq i \leq N)
- All P_i are distinct.
- 1 \leq U_j, V_j \leq N (1 \leq j \leq M)
- U_j \neq V_j (1 \leq j \leq M)
- The same pair (U_j, V_j) is not given more than once.
- All input values are integers.
Input
N M P_1 P_2 \cdots P_N U_1 V_1 U_2 V_2 \vdots U_M V_M
- The first line contains an integer N representing the number of mountain huts and an integer M representing the number of mountain trails, separated by a space.
- The second line contains integers P_1, P_2, \ldots, P_N representing the elevations of each mountain hut, separated by spaces. P_i represents the elevation of mountain hut i.
- The following M lines contain the information about the mountain trails. The j-th of these lines (the (2 + j)-th line of the entire input) contains the starting point U_j and the ending point V_j of the j-th trail, separated by a space. This means there exists a one-way mountain trail from mountain hut U_j to mountain hut V_j.
Output
Output in one line the maximum number of mountain huts that can be visited in a "good traverse".
Sample Input 1
5 4 10 20 30 40 5 1 2 2 3 3 4 1 3
Sample Output 1
4
Sample Input 2
4 4 100 50 30 200 1 2 1 3 2 4 3 4
Sample Output 2
1
Sample Input 3
8 9 15 30 10 45 25 50 35 60 1 2 1 5 2 4 5 7 7 4 4 6 6 8 1 3 3 5
Sample Output 3
6
Sample Input 4
15 20 5 50 10 45 15 40 20 35 25 30 55 60 65 70 75 1 3 3 5 5 7 7 9 9 10 10 11 11 12 12 13 13 14 14 15 1 2 2 4 4 6 6 8 1 5 3 7 5 9 9 11 7 10 2 6
Sample Output 4
11
Sample Input 5
1 0 1000000000
Sample Output 5
1
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 433 点
問題文
高橋君は、ある学校の遠足の引率担当です。この遠足には N 台のバスが使われており、バス 1 からバス N まで番号が振られています。バス i には弁当が S_i 個積み込まれており、P_i 人の生徒が乗車しています。
昼食の時間になると、各バスに乗っている生徒全員に弁当を 1 人あたり 1 個ずつ配る必要があります。弁当はバス間で移動させることができないため、バス i で全員に弁当を配れる条件は S_i \geq P_i です。弁当が余る分には問題ありません。
遠足の計画では、M 件の休憩プランが提案されています。休憩プラン j では、バス L_j からバス R_j までの連続した番号のバスがまとめて休憩所に停車し、昼食をとります。
休憩プラン j が配布可能であるとは、L_j \leq i \leq R_j を満たすすべてのバス i について S_i \geq P_i が成り立つことをいいます。逆に、L_j \leq i \leq R_j を満たすバス i の中に S_i < P_i となるものが 1 台でも存在すれば、そのプランは配布不可です。
各休憩プランについて、配布可能かどうかを判定してください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq 2 \times 10^5
- 0 \leq S_i \leq 10^9 ( 1 \leq i \leq N )
- 0 \leq P_i \leq 10^9 ( 1 \leq i \leq N )
- 1 \leq L_j \leq R_j \leq N ( 1 \leq j \leq M )
- 入力はすべて整数である。
入力
N M S_1 S_2 \ldots S_N P_1 P_2 \ldots P_N L_1 R_1 L_2 R_2 \vdots L_M R_M
- 1 行目には、バスの台数を表す整数 N と、休憩プランの数を表す整数 M が空白区切りで与えられる。
- 2 行目には、各バスに積まれた弁当の個数 S_1, S_2, \ldots, S_N が空白区切りで与えられる。
- 3 行目には、各バスに乗車している生徒の人数 P_1, P_2, \ldots, P_N が空白区切りで与えられる。
- 続く M 行にわたって、各休憩プランの対象バスの区間が与えられる。
- 3 + j 行目( 1 \leq j \leq M )では、休憩プラン j の区間の左端 L_j と右端 R_j が空白区切りで与えられる。
出力
M 行出力せよ。j 行目には、休憩プラン j が配布可能であれば Yes を、配布不可であれば No を出力せよ。
入力例 1
5 3 10 3 5 8 2 4 3 6 7 1 1 5 2 4 3 3
出力例 1
No No No
入力例 2
4 5 5 0 3 10 5 1 3 10 1 1 1 4 2 2 2 3 4 4
出力例 2
Yes No No No Yes
入力例 3
10 8 100 50 30 20 60 10 45 80 25 70 90 50 35 15 60 10 40 85 20 65 1 10 1 5 3 3 4 6 6 6 7 9 5 8 1 3
出力例 3
No No No Yes Yes No No No
Score : 433 pts
Problem Statement
Takahashi is a chaperone for a school field trip. The field trip uses N buses, numbered from Bus 1 to Bus N. Bus i has S_i boxed lunches loaded on it, and P_i students are riding in it.
When lunchtime comes, each student on every bus must receive exactly 1 boxed lunch. Since boxed lunches cannot be transferred between buses, the condition for all students on Bus i to receive a lunch is S_i \geq P_i. Having leftover lunches is not a problem.
For the field trip plan, M rest stop plans have been proposed. In rest stop plan j, buses with consecutive numbers from Bus L_j to Bus R_j stop together at a rest area to have lunch.
Rest stop plan j is said to be distributable if S_i \geq P_i holds for every bus i satisfying L_j \leq i \leq R_j. Conversely, if there exists even one bus i with L_j \leq i \leq R_j such that S_i < P_i, the plan is not distributable.
For each rest stop plan, determine whether it is distributable or not.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq 2 \times 10^5
- 0 \leq S_i \leq 10^9 ( 1 \leq i \leq N )
- 0 \leq P_i \leq 10^9 ( 1 \leq i \leq N )
- 1 \leq L_j \leq R_j \leq N ( 1 \leq j \leq M )
- All input values are integers.
Input
N M S_1 S_2 \ldots S_N P_1 P_2 \ldots P_N L_1 R_1 L_2 R_2 \vdots L_M R_M
- The first line contains two integers separated by a space: N, the number of buses, and M, the number of rest stop plans.
- The second line contains the number of boxed lunches loaded on each bus, S_1, S_2, \ldots, S_N, separated by spaces.
- The third line contains the number of students riding each bus, P_1, P_2, \ldots, P_N, separated by spaces.
- The following M lines give the bus range for each rest stop plan.
- The (3 + j)-th line ( 1 \leq j \leq M ) contains the left endpoint L_j and right endpoint R_j of the range for rest stop plan j, separated by a space.
Output
Output M lines. On the j-th line, output Yes if rest stop plan j is distributable, or No if it is not distributable.
Sample Input 1
5 3 10 3 5 8 2 4 3 6 7 1 1 5 2 4 3 3
Sample Output 1
No No No
Sample Input 2
4 5 5 0 3 10 5 1 3 10 1 1 1 4 2 2 2 3 4 4
Sample Output 2
Yes No No No Yes
Sample Input 3
10 8 100 50 30 20 60 10 45 80 25 70 90 50 35 15 60 10 40 85 20 65 1 10 1 5 3 3 4 6 6 6 7 9 5 8 1 3
Sample Output 3
No No No Yes Yes No No No