#K56632. Major Element Query

    ID: 30242 Type: Default 1000ms 256MiB

Major Element Query

Major Element Query

Given an array of n integers and m queries, each query asks whether a specific integer x is the major element in a specified subarray. The subarray is determined by the indices l and r (1-indexed). An integer x is considered a major element if its frequency in the subarray is strictly greater than half the length of that subarray.

Mathematically, for a subarray from l to r, let \(count_x\) be the number of occurrences of x. Then x is the major element if: \[ count_x > \frac{r-l+1}{2} \]

For each query, output "Yes" if x is the major element in the specified subarray, otherwise output "No".

inputFormat

The first line contains two space-separated integers n and m -- the number of elements in the array and the number of queries, respectively.

The second line contains n space-separated integers representing the array.

Each of the next m lines contains three space-separated integers l, r, and x, representing a query, where l and r are the 1-indexed bounds of the subarray and x is the element to check.

outputFormat

For each query, print a single line containing "Yes" if x is the major element in the subarray from l to r; otherwise, print "No".

## sample
7 3
3 1 2 3 3 2 3
1 4 3
2 6 2
3 7 3
No

No Yes

</p>