Codeforces Round #326 (Div. 2) A. Duff and Meat 水题
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
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 水题的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议
把这三个协议放到一起学习是因为这三个协议处于同一层,ARP协议用来找到目标主机的Ethernet网卡Mac地址,IP则承载要发送的消息.数据链路层可以从ARP得到数据的传送信息,而从IP得到要传输的数 ...
- Android 引用library project
1.如何将一个android工程作为库工程(library project) library project是作为jar包被其它android工程使用的,首先它也是普通的android工程.然后: 1 ...
- Android开源项目SlidingMenu深切解析
demo:http://download.csdn.net/detail/javadxz/6954819 SlidingMenu的是一种斗劲新的设置界面或设备界面结果,在主界面左滑或者右滑呈现设置界面 ...
- bjfu1235 两圆公共面积
给定两个圆,求其覆盖的面积,其实也就是求其公共面积(然后用两圆面积和减去此值即得最后结果). 我一开始是用计算几何的方法做的,结果始终不过.代码如下: /* * Author : ben */ #in ...
- 一行命令实现Android自动关机
前几天晚上失眠,实在睡不着觉,于是想用Nexus7听一听小野丽莎的歌,在安静祥和之中睡去(怎么感觉有点...)但是不能让平板总是这么循环播放吧(屋里吐槽Google Play Music),所以在平板 ...
- [GRYZ2015]工业时代
试题描述 小FF的第一片矿区已经开始运作了, 他着手开展第二片矿区……小FF的第二片矿区, 也是”NewBe_One“计划的核心部分, 因为在这片矿区里面有全宇宙最稀有的两种矿物,科学家称其为NEW矿 ...
- cxf 动态创建客户端,局域网能正常调用服务端,外网不能访问
- Android 用MediaCodec实现视频硬解码(转)
本文向你讲述如何用android标准的API (MediaCodec)实现视频的硬件编解码.例程将从摄像头采集视频开始,然后进行H264编码,再解码,然后显示.我将尽量讲得简短而清晰,不展示 那些不相 ...
- 现代程序设计 homework-08
现代程序设计 homework-08 第八次作业. 理解C++变量的作用域和生命周期 作用域就是一个变量可以被引用的范围,如:全局作用域.文件作用域.局部作用域:而生命周期就是这个变量可以被引用的时间 ...
- 最大连续子数组问题-homework-01
1)先写我的 github 的介绍: github 的域名:http://www.github.com/zhuifeng1022 登入 github 大概是下面的视图: 按照助教的方法:我已经建好了代 ...