CPCRC1D - Frequent Values
Given a non-decreasing series of integers a1, a2 ... an and indices 1 ≤ i ≤ j ≤ n, what is the maximum number of repeated numbers within ai, ai+1 ... aj?
Input
Input contains several test cases.
Each case begins with two integers 1 ≤ n, q ≤ 105.
Next line contains n integers (a1, a2 ... an), each one having a size of lower than or equal to 105.
In next q lines, there are queries. Each one contains two integers 1 ≤ i ≤ j ≤ n.
Input terminates when n, q are zero.
Output
For each query, print the maximum number of repetitions within numbers ai, ai+1 ... aj.
Example
Input: 10 3
1 1 3 3 3 3 5 10 10 10
2 3
1 10
5 10
0 0
Output: 1
4
3
Added by: | Tii |
Date: | 2010-10-25 |
Time limit: | 0.100s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | ULM Local contest 2007 |