atcoder#ABC229C. [ABC229C] Cheese

[ABC229C] Cheese

Score : 300300 points

Problem Statement

Takahashi, who works for a pizza restaurant, is making a delicious cheese pizza for staff meals. There are NN kinds of cheese in front of him. The deliciousness of the ii-th kind of cheese is AiA_i per gram, and BiB_i grams of this cheese are available. The deliciousness of the pizza will be the total deliciousness of cheese he puts on top of the pizza. However, using too much cheese would make his boss angry, so the pizza can have at most WW grams of cheese on top of it. Under this condition, find the maximum possible deliciousness of the pizza.

Constraints

  • All values in input are integers.
  • 1N3×1051 \le N \le 3 \times 10^5
  • 1W3×1081 \le W \le 3 \times 10^8
  • 1Ai1091 \le A_i \le 10^9
  • 1Bi10001 \le B_i \le 1000

Input

Input is given from Standard Input in the following format:

NN WW

A1A_1 B1B_1

A2A_2 B2B_2

\vdots

ANA_N BNB_N

Output

Print the answer as an integer.

3 5
3 1
4 2
2 3
15

The optimal choice is to use 11 gram of cheese of the first kind, 22 grams of the second kind, and 22 grams of the third kind. The pizza will have a deliciousness of 1515.

4 100
6 2
1 5
3 9
8 7
100

There may be less than WW grams of cheese in total.

10 3141
314944731 649
140276783 228
578012421 809
878510647 519
925326537 943
337666726 611
879137070 306
87808915 39
756059990 244
228622672 291
2357689932073