This problem is a Mooshak version of a UVA and SPOJ problem.
You are given a sequence of \(n\) integers \(a_1, a_2 , \ldots , a_n\) in non-decreasing order. In addition to that, you are given several queries consisting of indices \(i\) and \(j\). For each query, determine the most frequent value among the integers \(a_i, ..., a_j\).
The first input line contains two inters integer \(n\) and \(q\), respectively the amount of numbers and and queries.
The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\): the sequence of integers.
The next \(q\) lines describe the queries: each contains two integers \(i \, j\) describing the query range.
\(q\) lines, each with one integer: the number of occurrences of the most frequent value within the given range.
Example Input | Example Output |
10 3 -1 -1 1 1 1 1 3 10 10 10 2 3 1 10 5 10 |
1 4 3 |