Make RUN Great Again

시간 제한1초메모리 제한1024 MB

요약
다른 동아리들의 점수를 총 비용 K 미만으로 낮추면서 RUN의 순위가 X 이하가 되도록 RUN의 점수를 정할 때, 가능한 가장 낮은 점수를 구한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 이분 탐색, 누적 합
정답자
아직 제출이 없습니다

문제

KAIST Clubs Union is a student agency that delegates the university’s club funding based on the club’s activity records. Taein is a member of RUN — the marathon club of KAIST — and has joined the KAIST Clubs Union to make it richer.

There are N+1N+1 clubs at KAIST numbered from 11 to N+1N+1. RUN has a number N+1N+1. KAIST Clubs Union will assign the scores to each club, which is a non-negative integer. A club’s rank is then defined as (Number of clubs with a higher score than itself)+1(\text{Number of clubs with a higher score than itself}) +1. Note that there can be multiple clubs with the same rank. The funding opportunities for the club will be better if a club’s rank is lower.

Taein wishes to fabricate the scores in favor of RUN. Currently, every club except the RUN has their scores determined — for each 1≤i≤N1\le i\le N, club ii has a score of a_ia\_i. Taein can change each club’s score under the following conditions:

  • Each club’s score should not increase after Taein’s change.
  • Each club’s score must be a non-negative integer after Taein’s change.
  • If Taein reduces the club ii’s score by TT, the KAIST Clubs Union’s skepticism factor will increase by T×b_iT\times b\_i, where b_ib\_i is an integer decided for each club based on their influence and information gathering skills.
  • The total skepticism factor should be less than KK. If it is at least KK, it will trigger an internal investigation, which might cause trouble for Taein.

After the fabrication, Taein will fill in the score for RUN, which will finish the funding delegation process.

To avoid suspicion, Taein wishes to keep the score for RUN as low as possible while keeping the rank small enough for all needed funds. You should find the lowest possible initial score for RUN, such that the final rank of RUN is at most XX, and there exists a fabrication scheme that raises the skepticism factor by less than KK. Since RUN is a club as well, this score has to be a non-negative integer as well.

입력

The first line contains N,K,XN,K,X, separated by spaces.

The ii-th of the next NN lines contains a_ia\_i and b_ib\_i, separated by a space.

출력

Print the lowest possible initial score for RUN, such that the final rank of RUN is at most XX, and there exists a fabrication scheme that raises the skepticism factor by less than KK. Since RUN is a club as well, this score has to be a non-negative integer as well.

제한

  • 1≤N≤1051\leq N\leq 10^{5}
  • 1≤K≤10181\leq K\leq 10^{18}
  • 1≤X≤N+11\leq X\leq N+1
  • 0≤a_i≤1060\leq a\_{i}\leq 10^{6}
  • 1≤b_i≤1061\leq b\_{i}\leq 10^{6}

예제2

  1. 예제 1

    입력
    4 10 2
    100 1
    2 100000
    50 1
    30 8
    
    예상 출력
    41
    
  2. 예제 2

    입력
    5 15 3
    15 4
    24 1
    10 3
    24 2
    2 8
    
    예상 출력
    10