Roulette

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

요약
앨범 가격과 티켓 수, 경쟁자 티켓 S, 재추첨 비용 R이 주어질 때 확실히 당첨되는 최소 기대 비용을 구한다.
난이도

어려움10점 중 8점

유형
동적 계획법, 수학, 그리디
정답자
아직 제출이 없습니다

문제

You are a big fan of Korea’s biggest rockstar, Koosaga. Excitingly, Koosaga has announced a lottery event offering fans an once-in-a-lifetime opportunity for an one-on-one meeting.

Koosaga sells NN kinds of his albums. When you purchase the ii-th album, it costs you A_iA\_i won and you get B_iB\_i lottery tickets. Remember, you can purchase multiple copies of the same album if you wish.

On the day of the draw, a large roulette wheel containing cells with participant names, will decide the winner. Every cell on the wheel has an equal chance of being selected. The number of cells with your name corresponds to the number of lottery tickets you’ve amassed.

Koosaga will give the wheel a single spin to pick the winner. But even if luck isn’t on your side, there’s still hope! By paying RR won, you can request Koosaga to spin the wheel again. You can pay for as many re-spins as you desire.

Armed with insider knowledge, you’ve learned that the cumulative number of cells attributed to other participants is SS. You also have learned that none of them will opt for a re-spin. Only you will request a re-spin, if wanted.

Your challenge is to find an optimal strategy to guarantee your win with the minimum expected cost.

입력

The first line contains space-separated three integers, NN, SS, RR.

The next NN lines contain space-separated two integers, the ii-th line contains A_i,B_iA\_i,B\_i.

출력

Print a single line consists of space-separated two positive integers XX, YY.

XY\frac{X}{Y} must be the minimum expected cost to win and XX and YY must be coprime. It can be proven that the minimum expected cost can be expressed in this format.

제한

  • 1≤N≤100,0001\le N\le 100\\, 000
  • 1≤S≤1061\le S\le 10^6
  • 1≤R≤1061\le R\le 10^6
  • 1≤A_i≤300 (1≤i≤N)1\le A\_i\le 300\ (1\le i\le N)
  • 1≤B_i≤5,000 (1≤i≤N)1\le B\_i\le 5\\, 000\ (1\le i\le N)

예제1

  1. 예제 1

    입력
    3 11 3
    1 3
    2 7
    5 13
    
    예상 출력
    63 10