Logo
(追記) (追記ここまで)

21225번 - Index 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2.5 초 512 MB216987458.268%

문제

The h-index is an author-level metric that measures both the productivity and citation impact of the publications of a scientist or scholar. It is defined as the maximum value of h such that the given author has published h papers that have each been cited at least h times.

Our Mirko is nearing retirement. In his life he had published n papers and now q times he asks himself the following: “I wonder, what would be my h-index had I only published papers li through ri?”

Help him calculate the answers.

입력

The first line contains integers n and q (1 ≤ n, q ≤ 200 000), the number of papers and the number of questions.

The second line contains n integers pi (1 ≤ pi ≤ 200 000), where pi is the number of citations of the i-th paper.

The following q lines each contain two integers li and ri (1 ≤ li ≤ ri ≤ n), the endpoints from the i-th question.

출력

Output q lines. In the i-th line output the answer to the i-th question.

제한

서브태스크

번호배점제한
120

1 ≤ n, q ≤ 1000

240

1 ≤ n, q ≤ 50 000

350

No additional constraints.

예제 입력 1

7 6
3 2 3 1 1 4 7
3 4
1 7
1 6
4 5
1 2
5 7

예제 출력 1

1
3
3
1
2
2

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2020/2021 > Contest #6 5번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /