Practice on Toph

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

Exist or not exist

By bisnu_sarkar · Limits 2s, 512 MB

You will be given some numbers. Then there will contain some queries. In every query there will be given a range and a number. You have to say that, the given number exists in the range of values or not.

Input

First line will contain two integer number n and q. Where n dentoes number of elements in the array and q denotes total number of queries.(1 ≤ n ≤ 105, 1 ≤ q ≤ 105)

Then there will be contained n number of elements ai.(1 ≤ ai ≤ 109)

Then there will be contained q lines which contains three numbers l,r and x; where l,r denotes the range of index and x denotes the number which you have to check that exist or not exist.(1 ≤ l ≤ r ≤ n and 1 ≤ x ≤ 109)

Output

There will be q lines of output. In every line if the number is contained in given range of values than you have to print “YES” otherwise you have to print “NO”.

Sample

InputOutput
5 5
1 2 3 4 5
1 5 1
1 2 3
1 1 1
2 5 1
2 4 3
YES
NO
YES
NO
YES

Discussion

Statistics


64% Solution Ratio

skmonirEarliest, 1M ago

Ashraful_jnuFastest, 0.1s

marvel_coderLightest, 786 kB

mdgaziur001Shortest, 307B

Submit

Login to submit