https://www.luogu.com.cn/problem/CF16B
题目描述
A burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are mm containers, in the ii -th container there are a_{i}a
i
matchboxes, and each matchbox contains b_{i}b
i
matches. All the matchboxes are of the same size. The burglar's rucksack can hold nn matchboxes exactly. Your task is to find out the maximum amount of matches that a burglar can carry away. He has no time to rearrange matches in the matchboxes, that's why he just chooses not more than nn matchboxes so that the total amount of matches in them is maximal.
输入格式
The first line of the input contains integer nn ( 1<=n<=2·10^{8}1<=n<=2⋅10
8
) and integer mm ( 1<=m<=201<=m<=20 ). The i+1i+1 -th line contains a pair of numbers a_{i}a
i
and b_{i}b
i
( 1<=a_{i}<=10^{8},1<=b_{i}<=101<=a
i
<=10
8
,1<=b
i
<=10 ). All the input numbers are integer.
输出格式
Output the only number — answer to the problem.
一个窃贼进入了一个火柴仓库想要偷尽可能多的火柴。在这个仓库里有m个容器,第i个容器里有ai个火柴盒,并且每个盒子里有bi个火柴。所有火柴盒尺寸相同,窃贼的包能够装n个火柴盒,你要找到窃贼能偷走的最多火柴数。
第一行输入n和m接下来i+1行包含两个整数ai和bi所有数字都是整数
输出答案