Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Legacy of _sunny

By TarifEzaz · Limits 1s, 512 MB

Tasnim Imran Sunny is the fifth Bangladeshi red coder from Topcoder. This problem is to pay tribute to his unparalleled passion for problem solving.

You will be given an array $A$ of $N$ integers. After that, you will be given some queries on the following format:

$a$ $b$ $x$

In each query, you will have to answer if there exists an integer $x$ from index $a$ to $b$ in the given array.

Input

The first line of the input will have two integers $N$ and $Q$, where $N$ is the size of the array and $Q$ is the total number of queries.

Each of the next $N$ lines will have one integer $Ai$, indicating integer at the i’th position of array A.

Each of the following $Q$ lines will will be in the format a b x, where ( $0 <= a <= b < N$ ) and ( $0 <= x <= 10^9$ ).

$1 <=$ Size of the array $<= 100$

$0 <=$ Value of each element $<= 100$

$1 <=$ Number of queries $<= 100$

$1 <=$ Size of the array $<= 10^5$

$0 <=$ Value of each element $<= 100$

$1 <=$ Number of queries $<= 10^5$

$1 <=$ Size of the array $<=$ $10^5$

$0 <=$ Value of each element $<= 10^5$

$1 <=$ Number of queries $<= 10^5$

$1 <=$ Size of the array $<= 10^5$

$0 <=$ Value of each element $<= 10^5$

$1 <=$ Number of queries $<= 10^6$

Output

For each query, please print “Yes” if x exists in each query or “No” otherwise.

Sample

InputOutput
3 1
1
2
3
0 2 3
Yes

Statistics

59% Solution Ratio

Mr.HmianEarliest, 1M ago

user.545264Fastest, 0.2s

user.545264Lightest, 8.8 MB

ITisMAHMUDShortest, 450B