华东交通大学2016届新生选拔赛:1007 爱吃肉的保罗

来源:互联网 发布:如何给mac装win7 编辑:程序博客网 时间:2024/04/27 12:12

爱吃肉的保罗

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 11   Accepted Submission(s) : 8

Font: Times New Roman | Verdana | Georgia

Font Size:  

Problem Description

保罗爱吃肉,吃肉才开心,乔治为了让保罗持续n天都开心,决定帮他买肉,并且每天可以买任意多的肉。已知第i天保罗吃a[i]千克的肉和当天的肉的单位售价为p[i],为了节省费用,乔治向你请求帮助。你能帮助他吗?

Input

多组输入,每组第一行一个整数n,接下来n行,每行两个数a[i]和p[i]分别表示保罗当天要吃的肉的重量和当天的肉的售价,n<=10^5,0<=a[i],p[i]<=100.

Output

输出一个整数sum,表示乔治所花费用的最小值。

Sample Input

31 32 13 231 32 23 1

Sample Output

810


代码:

#include<iostream>#include<algorithm>#include<cstring>#include<cctype>#include<cstdio>#include<set>#include<cmath>#include<string>using namespace std;int main(){    int sum, minx, n, x, y;    while(~scanf("%d", &n)){        sum = 0, minx = 111;        for(int i = 0; i < n; i++){            scanf("%d %d", &x, &y);            minx = minx > y ? y : minx;            sum += x * minx;        }        cout<<sum<<endl;    }    return 0;}
0 0
原创粉丝点击