301989: CF377E. Cookie Clicker

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Cookie Clicker

题意翻译

小 D 在玩一个建筑类游戏,游戏中,小 D 的目标是收集 S 枚金币, 他一开始没有金币; 有 N 座可供选择的工厂,第 i 个工厂在建造时需要花费 $C_i$ 枚金币,建造之后的每秒会产出 $V_i$ 枚金币(如果该工厂处于运转状态); 由于一些不可抗力,同一秒内只能有一个工厂在运转; 小 D 可以在每一秒开始前进行任意次操作,操作包括建筑新的工厂,选定下一秒运转的工厂; 若在某一秒结束后,小 D 拥有了至少 S 枚金币,游戏结束; 由于这个游戏实在是太无聊了,小 D 想知道这个游戏最少在多少秒后结束; 游戏保证小 D 可以完成目标。

题目描述

Kostya is playing the computer game Cookie Clicker. The goal of this game is to gather cookies. You can get cookies using different buildings: you can just click a special field on the screen and get the cookies for the clicks, you can buy a cookie factory, an alchemy lab, a time machine and it all will bring lots and lots of cookies. At the beginning of the game (time 0), Kostya has 0 cookies and no buildings. He has $ n $ available buildings to choose from: the $ i $ -th building is worth $ c_{i} $ cookies and when it's built it brings $ v_{i} $ cookies at the end of each second. Also, to make the game more interesting to play, Kostya decided to add a limit: at each moment of time, he can use only one building. Of course, he can change the active building each second at his discretion. It's important that Kostya is playing a version of the game where he can buy new buildings and change active building only at time moments that are multiples of one second. Kostya can buy new building and use it at the same time. If Kostya starts to use a building at the time moment $ t $ , he can get the first profit from it only at the time moment $ t+1 $ . Kostya wants to earn at least $ s $ cookies as quickly as possible. Determine the number of seconds he needs to do that.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ s $ ( $ 1<=n<=2·10^{5} $ , $ 1<=s<=10^{16} $ ) — the number of buildings in the game and the number of cookies Kostya wants to earn. Each of the next $ n $ lines contains two integers $ v_{i} $ and $ c_{i} $ ( $ 1<=v_{i}<=10^{8} $ , $ 0<=c_{i}<=10^{8} $ ) — the number of cookies the $ i $ -th building brings per second and the building's price.

输出格式


Output the only integer — the minimum number of seconds Kostya needs to earn at least $ s $ cookies. It is guaranteed that he can do it.

输入输出样例

输入样例 #1

3 9
1 0
2 3
5 4

输出样例 #1

6

输入样例 #2

3 6
1 0
2 2
5 4

输出样例 #2

5

输入样例 #3

3 13
1 0
2 2
6 5

输出样例 #3

7

输入样例 #4

1 10000000000000000
1 0

输出样例 #4

10000000000000000

Input

题意翻译

小 D 在玩一个建筑类游戏,游戏中,小 D 的目标是收集 S 枚金币, 他一开始没有金币; 有 N 座可供选择的工厂,第 i 个工厂在建造时需要花费 $C_i$ 枚金币,建造之后的每秒会产出 $V_i$ 枚金币(如果该工厂处于运转状态); 由于一些不可抗力,同一秒内只能有一个工厂在运转; 小 D 可以在每一秒开始前进行任意次操作,操作包括建筑新的工厂,选定下一秒运转的工厂; 若在某一秒结束后,小 D 拥有了至少 S 枚金币,游戏结束; 由于这个游戏实在是太无聊了,小 D 想知道这个游戏最少在多少秒后结束; 游戏保证小 D 可以完成目标。

加入题单

上一题 下一题 算法标签: