303023: CF588A. Duff and Meat

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Duff and Meat

题意翻译

Duff嗜好吃肉。Malek 想让他开心 _n_ 个日子,使得她在第 _i_ 天保持开心,她需要在那天吃_ai_ 千克的肉。 在市中心有一个大超市,Malek想从这里去那买点肉。在第i天,超市的肉价是pi美元一斤。Malek知道所有的a1,...,an 和p1,...,pn,在每天,他可以买任意数量的肉,当然,他也可以留存一些肉备将来使用。 Malek 炖肉炖的有点疲惫,所以他向你求助,帮助他最小化一下他让Duff开心n天所需要的花费。 输入:第一行是一个整数n,代表天数。在接下来的n行里,第i行包括两个整数ai,pi,代表Duff那天要吃的肉和那天的肉价。 输出:输出一个整数n,代表使Duff在n天内开心所花费的最小值。

题目描述

Duff is addicted to meat! Malek wants to keep her happy for $ n $ days. In order to be happy in $ i $ -th day, she needs to eat exactly $ a_{i} $ kilograms of meat. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF588A/e0a1a4af93fd8d07e258d5dc1cd3e48db986dfbc.png)There is a big shop uptown and Malek wants to buy meat for her from there. In $ i $ -th day, they sell meat for $ p_{i} $ dollars per kilogram. Malek knows all numbers $ a_{1},...,a_{n} $ and $ p_{1},...,p_{n} $ . In each day, he can buy arbitrary amount of meat, also he can keep some meat he has for the future. Malek is a little tired from cooking meat, so he asked for your help. Help him to minimize the total money he spends to keep Duff happy for $ n $ days.

输入输出格式

输入格式


The first line of input contains integer $ n $ ( $ 1<=n<=10^{5} $ ), the number of days. In the next $ n $ lines, $ i $ -th line contains two integers $ a_{i} $ and $ p_{i} $ ( $ 1<=a_{i},p_{i}<=100 $ ), the amount of meat Duff needs and the cost of meat in that day.

输出格式


Print the minimum money needed to keep Duff happy for $ n $ days, in one line.

输入输出样例

输入样例 #1

3
1 3
2 2
3 1

输出样例 #1

10

输入样例 #2

3
1 3
2 1
3 2

输出样例 #2

8

说明

In the first sample case: An optimal way would be to buy 1 kg on the first day, 2 kg on the second day and 3 kg on the third day. In the second sample case: An optimal way would be to buy 1 kg on the first day and 5 kg (needed meat for the second and third day) on the second day.

Input

题意翻译

Duff嗜好吃肉。Malek 想让他开心 _n_ 个日子,使得她在第 _i_ 天保持开心,她需要在那天吃_ai_ 千克的肉。 在市中心有一个大超市,Malek想从这里去那买点肉。在第i天,超市的肉价是pi美元一斤。Malek知道所有的a1,...,an 和p1,...,pn,在每天,他可以买任意数量的肉,当然,他也可以留存一些肉备将来使用。 Malek 炖肉炖的有点疲惫,所以他向你求助,帮助他最小化一下他让Duff开心n天所需要的花费。 输入:第一行是一个整数n,代表天数。在接下来的n行里,第i行包括两个整数ai,pi,代表Duff那天要吃的肉和那天的肉价。 输出:输出一个整数n,代表使Duff在n天内开心所花费的最小值。

加入题单

上一题 下一题 算法标签: