Under construction

Still being built. Things may change

Carrot Click Game

Interview

Time limit2sMemory limit1024 MB

Summary
Given N speed effects with costs A_i and speed gains B_i, find the most carrots Eric can hold after K seconds of clicking and buying.
Level

Medium5 of 10

Topics
Dynamic programming, Greedy
Solved
No attempts yet

Problem

Eric had too much free time during his vacation, so he decided to make a game called Carrot Click Game and play it himself.

At the start of the game, Eric has 0 carrots and ss is 1.

Every second, he can do one of the following two actions.

  1. Click the mouse to get ss carrots.
  2. Choose an integer ii (1≤i≤N1 \le i \le N) and pay AiA_i carrots to buy the ii-th speed effect. Right after the purchase, ss increases by BiB_i. (A speed effect bought earlier can be bought again.)

Eric used up all his energy building the game, so find the maximum number of carrots he can have after playing for KK seconds.

Input

The first line contains two integers NN and KK, separated by a space.

Each of the next NN lines contains two integers AiA_i and BiB_i, separated by a space, for the ii-th speed effect.

Output

Print the maximum number of carrots Eric can have after playing the game for KK seconds.

Constraints

  • 1≤N,K≤1001 \le N, K \le 100
  • 1≤Ai,Bi≤501 \le A_i, B_i \le 50

Examples1

  1. Example 1

    Input
    2 4
    1 2
    2 5
    
    Expected output
    6