麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

588A. Duff and Meat

2019-11-14 08:51:16
字體:
來源:轉載
供稿:網友
A. Duff and Meattime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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 aikilograms of meat.

There is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, they sell meat for pi dollars per kilogram. Malek knows all numbers a1,?...,?an and p1,?...,?pn. 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.

Input

The first line of input contains integer n (1?≤?n?≤?105), the number of days.

In the next n lines, i-th line contains two integers ai and pi (1?≤?ai,?pi?≤?100), the amount of meat Duff needs and the cost of meat in that day.

Output

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

Examplesinput
31 32 23 1output
10input
31 32 13 2output
8Note

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.

#include <iostream>#define INF 1000000000using namespace std;int main(){    int n,a,p,ans=0,price=INF;    cin>>n;    for(int i=0;i<n;i++)    {        cin>>a>>p;        price=min(price,p);        ans+=price*a;    }    cout<<ans;    return 0;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 羞羞视频在线免费 | 国产成人精品区 | 欧美黄一级 | 羞羞视频.www在线观看 | 国产精品99久久久久久宅女 | 欧美精品一区二区性色 | 久草在线观看福利视频 | 天天草天天操 | japanesexxxx24videofree| 久久人| 久久久精品视频国产 | 成人福利电影在线观看 | 天天干天天碰 | 久久吊 | 日日操日日操 | 国产午夜精品久久久久 | 久久综合av | 亚洲综人网 | 欧美成人一区二区三区电影 | 性爱视频在线免费 | 精品国产91一区二区三区 | 中文在线日韩 | 国产精品久久99精品毛片三a | 日韩视频网址 | 国产一级在线看 | 成人精品一区二区三区中文字幕 | 国产精选久久久 | 色婷婷av一区二区三区久久 | 四季久久免费一区二区三区四区 | 欧美性生活区 | 777zyz色资源站在线观看 | 369看片你懂的小视频在线观看 | www.狠狠插.com| 72pao成人国产永久免费视频 | 精品国产九九九 | 特级黄aaaaaaaaa毛片 | 92看片淫黄大片欧美看国产片 | 国产一级一片免费播放 | 亚洲福利视频52 | 亚洲一区在线国产 | 天天草天天操 |