시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB199827841.935%

문제

Being a responsible young adult, you have decided to start planning for retirement. Doing some back-of-the-envelope calculations, you figured out you need at least M euros to retire comfortably.

You are currently broke, but fortunately a generous gazillionaire friend has offered to lend you an arbitrary amount of money (as much as you need), without interest, to invest in the stock market. After making some profits you will then return the original sum to your friend, leaving you with the remainder.

Available to you are n investment opportunities, the i-th of which costs ci euros. You also used your computer science skills to predict that the i-th investment will earn you pi euros per day. What is the minimum number of days you need before you can pay back your friend and retire?

For example, consider the first sample. If you buy only the second investment (which costs 15 euros) you will earn p2 = 10 euros per day. After two days you will have earned 20 euros, exactly enough to pay off your friend (from whom you borrowed 15 euros) and retire with the remaining profits (5 euros). There is no way to make a net amount of 5 euros in a single day, so two days is the fastest possible.

입력

  • The first line contains the number of investment options 1 ≤ n ≤ 105 and the minimum amount of money you need to retire 1 ≤ M ≤ 109.
  • Then, n lines follow. Each line i has two integers: the daily profits of this investment 1 ≤ pi ≤ 109 and its initial cost 1 ≤ ci ≤ 109.

출력

Print the minimum number of days needed to recoup your investments and retire with at least M euros, if you follow an optimal investment strategy.

예제 입력 1

2 5
4 10
10 15

예제 출력 1

2

예제 입력 2

4 10
1 8
3 12
4 17
10 100

예제 출력 2

6

예제 입력 3

3 5
4 1
9 10
6 3

예제 출력 3

1

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2018 F번

  • 문제를 만든 사람: Timon Knigge