A. Duff and Meat

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/588/problem/A

Description

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 forn 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.

Sample Input

3
1 3
2 2
3 1

Sample Output

10

HINT

题意

每一天你得吃掉a[i]公斤的东西,然后在这天,这个东西的价格为p[i]

然后问你最少花费多少,就可以每天吃a[i]啦

题解:

对于每一天,肯定就用到目前为止的最少价格买啦

扫一遍就好了,边扫边更新

代码:

#include<iostream>
#include<math.h>
#include<stdio.h>
#include<map>
using namespace std; long long a[];
long long p[];
long long minn;
int main()
{
int n;
scanf("%d",&n);
minn = 9999LL;
for(int i=;i<=n;i++)
scanf("%lld%lld",&a[i],&p[i]);
long long ans = ;
for(int i=;i<=n;i++)
{
minn = min(minn,p[i]);
ans += minn*a[i];
}
cout<<ans<<endl;
}

Codeforces Round #326 (Div. 2) A. Duff and Meat 水题的更多相关文章

  1. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  2. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  3. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  4. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  5. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

  6. Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题

    A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...

  7. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

  8. Codeforces Round #326 (Div. 2) D. Duff in Beach dp

    D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...

  9. Codeforces Round #326 (Div. 2) C. Duff and Weight Lifting 水题

    C. Duff and Weight Lifting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

随机推荐

  1. 【转】visual studio 2012进行C语言开发[图文]

    原文网址:http://blog.csdn.net/chengyafei0104/article/details/9826025 现在大家计算机大概都脱离XP了,so,之前蛮多可以用的编译器,可能放在 ...

  2. Android-AnimationDrawable(二)

    首先可以先定义一个逐帧播放的xml: <?xml version="1.0" encoding="utf-8"?> <animation-li ...

  3. hadoop中日志聚集问题

    遇到的问题: 当点击上面的logs时,会出现下面问题: 这个解决方案为: By default, Hadoop stores the logs of each container in the nod ...

  4. Delphi RICHEDIT中插入图象

    unit InsRich;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  5. <转>写给浮躁的IT同仁(请不要做浮躁的人)

    1.不要看到别人的回复第一句话就说:给个代码吧!你应该想想为什么.当你自己想出来再参考别人的提示,你就知道自己和别人思路的差异. 2.初学者请不要看太多太多的书那会误人子弟的,先找本系统的学,很多人用 ...

  6. 详解Asp.net MVC DropDownLists

    Asp.net MVC中的DropDownLists貌似会让一开始从Asp.net Forms转过来的程序员造成不少迷惑.这篇文章讲述了为了使用DropDownLists,你需要在Asp.Net MV ...

  7. C#条件语句、循环语句

    一.程序的三种结构 顺序结构 分支结构 循环结构 二.条件语句if 语句是最有用的控制结构之一. if … else …语句的语法: if (布尔表达式)执行操作的语句  或if (布尔表达式)执行操 ...

  8. Eclipse中设置在创建新类时自动生成注释的方法

     windows–>preference Java–>Code Style–>Code Templates code–>new Java files 编辑它 ${filecom ...

  9. login:用户登陆的意思

    login:用户登陆的意思 在思科的设备上有两种登录方式: 一种是本地方式,使用console口: 一种是远程方式(或者叫做网络方式):使用的是telnet等 1.默认情况下,思科的远程访问是禁止的. ...

  10. 微信公众平台开发 ACCESS TOKEN

    获取access token 返回 access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token.正常情况下access_token有效期为7200秒,重复获取将 ...