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

14170번 - Counting Haybales 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB126172258758.119%

문제

Farmer John has just arranged his N haybales (1≤N≤100,000) at various points along the one-dimensional road running across his farm. To make sure they are spaced out appropriately, please help him answer Q queries (1≤Q≤100,000), each asking for the number of haybales within a specific interval along the road.

입력

The first line contains N and Q.

The next line contains N distinct integers, each in the range 0…1,000,000,000, indicating that there is a haybale at each of those locations.

Each of the next Q lines contains two integers A and B (0≤A≤B≤1,000,000,000) giving a query for the number of haybales between A and B, inclusive.

출력

You should write Q lines of output. For each query, output the number of haybales in its respective interval.

제한

예제 입력 1

4 6
3 2 7 5
2 3
2 4
2 5
2 7
4 6
8 10

예제 출력 1

2
2
3
4
1
0

힌트

출처

Olympiad > USA Computing Olympiad > 2016-2017 Season > USACO 2016 December Contest > Silver 1번

  • 문제의 오타를 찾은 사람: jason9319
(追記) (追記ここまで)

출처

대학교 대회

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

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