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 AA of NN integers. After that, you will be given some queries on the following format:

aa bb xx

In each query, you will have to answer if there exists an integer xx from index aa to bb in the given array.

Input

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

Each of the next NN lines will have one integer AiAi, indicating integer at the i’th position of array A.

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

Subtask 1 (10 points):

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

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

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

Subtask 2 (20 points):

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

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

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

Subtask 3 (30 points):

1<=1 <= Size of the array <=<= 10510^5

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

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

Subtask 4 (40 points):

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

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

1<=1 <= Number of queries <=106<= 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

    Discussion

    Statistics


    59% Solution Ratio

    Mr.HmianEarliest, 1M ago

    user.545264Fastest, 0.2s

    user.545264Lightest, 8.8 MB

    ITisMAHMUDShortest, 450B

    Submit

    Login to submit

    Editorial

    This problem can be solved in a few ways: For easy sub-task, a simple for loop checking the query ...

    Related Contests

    Toph uses cookies. By continuing you agree to our Cookie Policy.