A9344 | Cookie Clicker
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted