Under construction

Still being built. Things may change

Gas Stations

Interview

Time limit1sMemory limit1024 MB

Summary
Given gas stations with positions and prices, a budget, and a tank capacity, find the farthest point the car can reach.
Level

Medium6 of 10

Topics
Greedy, Stack
Solved
No attempts yet

Problem

Michelle and Marie are taking a road trip in their car. They will drive along a long straight road with nn gas stations, numbered from 1 to nn in order along the road. At the start of the road, the car is in the city, and gas station 1 is at the same spot.

Gas station ii is xix_i kilometers from the beginning of the road and sells gas for pip_i dollars per liter. Gas can only be bought in whole liters. One liter of gas is enough to drive 1 unit of distance. The gas tank has a capacity of CC liters, and the tank starts empty.

Michelle and Marie have BB dollars to spend on gas. They do not plan to come back. How far along the road can they drive?

Input

The first line contains three integers nn, BB, and CC, the number of gas stations, the total budget in dollars, and the tank capacity in liters (1≤n≤1051 \le n \le 10^5; 1≤B≤1091 \le B \le 10^9; 1≤C≤1091 \le C \le 10^9).

Each of the next nn lines contains two integers xix_i and pip_i, the position of the ii-th gas station and its gas price (0=x1<x2<…<xn≤1090 = x_1 < x_2 < \ldots < x_n \le 10^9; 1≤pi≤1091 \le p_i \le 10^9).

Output

Print one integer, the maximum distance that can be driven along the road.

Hint

In the sample test, they can buy 1 liter of gas at the first station and drive 1 unit. Then they buy 5 liters at the second station and drive 3 more units to reach the third station. At that point the tank holds 2 liters. They buy 1 more liter and drive 3 more units, ending the trip at distance 7.

Examples1

  1. Example 1

    Input
    3 10 5
    0 3
    1 1
    4 2
    
    Expected output
    7