아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Contest Advancement

면접 대비

시간 제한2초메모리 제한2048 MB

요약
학교별 상한 c를 지키면서 상위 k개 팀을 선발하되 정원이 차지 않으면 남은 자리는 순위대로 채우는 문제이다.
난이도

보통10점 중 4점

유형
그리디, 해시맵, 구현
정답자
아직 제출이 없습니다

문제

You are the RCD for your regional contest. It just ended and you now need to decide which teams qualify for the next level of competition. The teams are uniquely ranked (there are no ties). The next level has a limit on how many teams from any given school can participate. However, if that limit causes there to be not enough teams advancing, the remaining slots will be filled by teams from schools over the limit. If this happens, you will always give preference to higher-ranking teams, even if it means many teams from the same school advancing.

Output, in rank order, the teams that qualify for the next contest.

입력

The first line of input contains three integers nn, kk (1≤k<n≤1051 \leq k < n \leq 10^5) and cc (1≤c≤n 1 \leq c \leq n), where nn is the number of teams in the competition, kk is the number of teams that will advance, and cc is the limit on the number of teams that may advance from any given school.

Each of the next nn lines contains two integers tt and ss (1≤t,s≤n1 \le t,s \le n). Each line describes a team, with tt being the team's unique ID, and ss indicating the team's school. All team IDs will be distinct. The teams will be listed in rank order, with the highest ranking teams first.

출력

Output kk lines. On each line output a single integer, which is the ID of a team. List the IDs of the teams that qualified to advance in rank order.

예제1

  1. 예제 1

    입력
    10 7 3
    3 9
    1 9
    4 9
    5 9
    9 7
    2 7
    6 7
    7 7
    8 5
    10 5
    
    예상 출력
    3
    1
    4
    9
    2
    6
    8