当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3368:Frequent values

题目描述

You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, determine the most frequent value among the integers ai , ... , aj.

输入解释

The input consists of several test cases. Each test case starts with a line containing two integers n and q (1 ≤ n, q ≤ 100000). The next line contains n integers a1 , ... , an (-100000 ≤ ai ≤ 100000, for each i ∈ {1, ..., n}) separated by spaces. You can assume that for each i ∈ {1, ..., n-1}: ai ≤ ai+1. The following q lines contain one query each, consisting of two integers i and j (1 ≤ i ≤ j ≤ n), which indicate the boundary indices for the
query.

The last test case is followed by a line containing a single 0.

输出解释

For each query, print one line with one integer: The number of occurrences of the most frequent value within the given range.

输入样例
10 3
-1 -1 1 1 1 1 3 10 10 10
2 3
1 10
5 10
0
输出样例
1
4
3

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Ulm Local 2007

源链接: POJ-3368

最后修改于 2020-10-29T06:59:54+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536