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

16614번 - Collecting Stars 다국어

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

문제

You are planning to complete the latest Super Mario game as fast as you can. In this game, there are n stars that can be collected and your objective is to collect any k of them. Each star takes a certain amount of time to get. After collecting a star, Mario will reappear at the start of the game, so the time taken to collect any sequence of stars is the same regardless of the order that they are collected in. However, some stars do not become available for collection until a certain quantity of stars has already been collected.

Given a description of the stars, determine the fastest time in which you could collect k of them or determine that it is impossible to do so.

입력

The input starts with a line containing two integers n (1 ≤ n ≤ 200 000), which is the number of stars, and k (1 ≤ k ≤ n), which is the number of stars you must collect.

The following n lines describe the stars. Each of these lines contains two integers t (1 ≤ t ≤ 109), which is the amount of time it will take to collect the star, and d (0 ≤ d < n), which is the number of stars that must be collected before the star is available.

출력

Display the minimum amount of time to collect k stars. If you cannot collect k stars, display IMPOSSIBLE.

제한

예제 입력 1

5 4
1 0
2 1
3 1
2 3
4 0

예제 출력 1

8

예제 입력 2

3 3
1 0
1 2
4 2

예제 출력 2

IMPOSSIBLE

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2018 ACM South Pacific Programming Contest C번

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

출처

대학교 대회

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

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