Sequence and Queries 6
Time limit2sMemory limit512 MB
For each query range [i, j], report the highest number of occurrences of any single value inside that range.
- Level
Hard9 of 10
- Topics
- Segment tree, Divide and conquer, Binary search, Prefix sum
- Solved
- No attempts yet
Problem
You are given a sequence of length . Write a program that processes the following query on this sequence.
i j: print how many times the most frequent value among occurs.
Input
The first line contains the length of the sequence ().
The second line contains separated by spaces. ()
The third line contains the number of queries ().
Each of the next lines contains one query , . ()
Output
Print the answer to each query on its own line, in the order the queries are given.