CF377E.Cookie Clicker

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

科斯佳正在玩电脑游戏《饼干点击器》。这款游戏的目标是收集饼干。你可以通过不同的建筑来获取饼干:你可以直接点击屏幕上的一个特殊区域,通过点击获得饼干;你也可以购买饼干工厂、炼金实验室、时间机器等建筑,它们都会持续为你带来大量饼干。

游戏开始时(时间为 0),科斯佳拥有 0 块饼干,且没有任何建筑。他有 nn 种可选的建筑:第 ii 种建筑的价格为 cic_i 块饼干,建成后每秒末可产生 viv_i 块饼干。此外,为了增加游戏的趣味性,科斯佳添加了一条限制:在任意时刻,他只能启用一种建筑。当然,他可以按自己的意愿,在每秒初更换当前启用的建筑。

需要注意的是,科斯佳所玩的版本中,他仅能在整数秒时刻(即时间点为 1 秒、2 秒、3 秒……)购买新建筑或更换启用的建筑。科斯佳可以在同一时刻购买一座新建筑并立即启用它。若科斯佳在时刻 tt 开始启用某座建筑,则他最早能在时刻 t+1t+1 获得该建筑产生的第一份收益。

科斯佳希望以最短时间赚取至少 ss 块饼干。请确定他达成目标所需的最少秒数。

输入格式

The first line contains two integers n and s (1 ≤ n ≤ 2·105, 1 ≤ s ≤ 1016) — 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 ≤ 108, 0 ≤ c__i ≤ 108) — the number of cookies the i-th building brings per second and the building's price.

第一行包含两个整数 nn 和 ss(1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5,1≤s≤10161 \leq s \leq 10^{16})—— 分别表示游戏中建筑物的数量以及科斯佳希望获得的饼干总数。

接下来的 nn 行中,每行包含两个整数 viv_i 和 cic_i(1≤vi≤1081 \leq v_i \leq 10^8,0≤ci≤1080 \leq c_i \leq 10^8)—— 分别表示第 ii 座建筑物每秒产生的饼干数量及其价格。

输出格式

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.

输出唯一的整数——Kostya 获得至少 ss 块饼干所需的最少秒数。题目保证他一定能做到。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页