luogu#P1997. faebdc 的烦恼
faebdc 的烦恼
Background
Update on July 29, 2024: Added a set of hack testdata; previously, all testdata satisfied .
Since crushing NOIP2013, Niaoge (faebdc) has kept studying hard, solving problems on various OJs every day, and contests are usually a breeze for him. But today he ran into a small problem: at an "Orz Niaoge Cup", there were just too many problems! Niaoge felt dizzy and needs your help.
Problem Description
There are problems in this contest, each with a difficulty value . Since the ace coder wangxz has already sorted these difficulty values in ascending order for Niaoge, he does not want to know which problems are easy or hard; he only wants to know, among some problems , how many times the most frequent difficulty value appears.
Your task is: for each query , tell him, among the problems from to , the number of occurrences of the most frequent difficulty value (there are queries in total).
If you succeed in helping Niaoge, he will take you through the NOI Qualifier.
Input Format
Each test point contains exactly one set of testdata.
The first line contains two integers, the number of problems and the number of queries .
The second line has integers; the -th integer is the difficulty of the -th problem.
Then follow lines, each with two integers , representing one query.
Output Format
For each query, output a single integer on its own line as the answer.
9 1
1 1 1 2 2 3 3 4 4
3 8
2
Hint
Constraints
对于全部的测试点,保证 ,,,。
Translated by ChatGPT 5