894. Maximum Unit of Boxes

1

Easy

You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where
boxTypes[i] = [numberOfBoxes(i) , numberOfUnitsPerBox(i)]: * NumberOfBoxes(i) is the number of boxes of type i. * numberOfUnitsPerBox(i) is the number of units in each box of the type i.

You are also given an integer truckSize, which is the maximum number of boxes that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed truckSize. Print the maximum total number of units that can be put on the truck.

Input Format

First Line contains two space separated integers N and K(truck size) .
Next N Lines contains boxtype[i] where each boxtype is of size 2 .

Output Format

An integer denoting the maximum unit of boxes .

Example

Input

4 10 5 10 2 5 4 7 3 9

Output

91

Constraints

1 <= boxTypes.length <= 1000
1 <= numberOfBoxes(i), numberOfUnitsPerBox(i) <= 1000
1 <= truckSize <= 106
Loading...

View Submissions

Console