This page is still under construction.

Parts of this page are still being built. What you see may change.

Fortress Defense

Interview

Time limit2sMemory limit512 MB

Summary
Distribute exactly s defenders among wall sections, where each defender in section i repels k_i attackers, to minimize the total attackers that break through.
Level

Medium6 of 10

Topics
Greedy, Sorting, Math, Binary search
Solved
No attempts yet

Problem

The wall of a besieged fortress consists of nn sections numbered from 1 to nn. Reconnaissance reports that in the next assault the enemy will send aia_i soldiers to attack section ii. To defend the fortress, ss defenders will be sent to the sections of the wall.

The sections differ in the quality of their fortifications, which makes defense effectiveness differ as well. One defender in section ii can repel the attack of kik_i attackers.

Suppose xix_i defenders are sent to section ii. If the number of attackers does not exceed xi⋅kix_i \cdot k_i, then no attacker breaks into the fortress through this section. Otherwise, ai−xi⋅kia_i - x_i \cdot k_i attackers break into the fortress.

Write a program that distributes the defenders among the sections so that their total number equals ss and as few attackers as possible break into the fortress.

Input

The first line contains integers nn, the number of sections of the wall, and ss, the number of defenders of the fortress (1≤n≤100 0001 \leq n \leq 100\,000; 1≤s≤1091 \leq s \leq 10^9).

The next nn lines contain two integers each, aia_i and kik_i, the total number of attackers on section ii of the wall and the number of attackers that one defender of this section can repel (1≤ai,ki≤1091 \leq a_i, k_i \leq 10^9).

Output

The output must contain a single integer: the minimum number of attackers that break into the fortress.

Hint

In the first test, if all 10 defenders are placed on the only section, they can repel all the attackers and nobody gets into the fortress. In the second sample, one can, for example, send two defenders to the first section and one to the third.

Examples2

  1. Example 1

    Input
    1 10
    8 1
    
    Expected output
    0
    
  2. Example 2

    Input
    3 3
    4 2
    1 1
    10 8
    
    Expected output
    3