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

建议使用的浏览器:

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

6278:Just $h$-index

题目描述
The $h$-index of an author is the largest $h$ where he has at least $h$ papers with citations not less than $h$.

Bobo has published $n$ papers with citations $a_1, a_2, \dots, a_n$ respectively.
One day, he raises $q$ questions. The $i$-th question is described by two integers $l_i$ and $r_i$, asking the $h$-index of Bobo if has *only* published papers with citations $a_{l_i}, a_{l_i + 1}, \dots, a_{r_i}$.
输入解释
The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains two integers $n$ and $q$.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$.
The $i$-th of last $q$ lines contains two integers $l_i$ and $r_i$.
输出解释
For each question, print an integer which denotes the answer.

## Constraint

* $1 \leq n, q \leq 10^5$
* $1 \leq a_i \leq n$
* $1 \leq l_i \leq r_i \leq n$
* The sum of $n$ does not exceed $250,000$.
* The sum of $q$ does not exceed $250,000$.
输入样例
5 3
1 5 3 2 1
1 3
2 4
1 5
5 1
1 2 3 4 5
1 5
输出样例
2
2
2
3
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6278

最后修改于 2020-10-25T23:29:55+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 132768/132768K(Java/Others)