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 ...
随机推荐
- 用defy来潜水最终还是挂了........
defy526是6级,,不过好像这次我用来潜过去不足2米还是挂掉了... 国际通用的防水级别认证体系: IPX-0 没有防水保护 IPX-1 设备在正常操作状态下,可以提供相当于3-5毫米/分钟降雨的 ...
- Linux iostat监测IO状态
Linux iostat监测IO状态 http://www.orczhou.com/index.php/2010/03/iostat-detail/
- windows主线程等待子线程退出卡死问题
在windows下调用_beginthread创建子线程并获得子线程id(函数返回值),如果子线程很快退出,在主线程中调用WaitForSingleObject等待该线程id退出,会导致主线程卡死.需 ...
- RecordWriter接口解析
RecordWriter是将Map/Reduce结果(Key-Value)输出到文件系统中. /** * <code>RecordWriter</code> writes th ...
- java web 学习十四(JSP原理)
一.什么是JSP? JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术. JSP这门技术的最大的特点在于,写jsp就像在写h ...
- Android中ListView中有button,checkbox,GridView时事件问题
最近做项目,用到了listview的item的一些问题,现在抽空把它们总结一下: 转载请表明出处:http://blog.csdn.net/wdaming1986/article/details/67 ...
- springmvc的一些优化设置
1.配置文件的优化: 无需使用 <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotatio ...
- ORA-15018: diskgroup cannot be created
创建ASM磁盘组的时候出错,具体报错如下: SQL> create diskgroup kel external redundancy disk 'ORCL:KEL1','ORCL:KEL2'; ...
- LeetCode题解——Regular Expression Matching
题目: 正则表达式的匹配,'.'能匹配任何一个字符,'*'之前必须有一个字符,两个结合起来表示之前那个字符出现0到无穷次. 解法: 一定要注意'*'必须结合前面的字符一起使用. 代码: class S ...
- Hadoop2.0新特性-持续追加【干货】
1.NAME NODE HA 2.NAME NODE Federation 3.HDFS 快照(目录快照) 4.HDFS 缓存 5.HDFS ACL 6.异构层级存储结构 -------------- ...