Duff and Meat - CF 588A
题目大意:有一个人他有每天需要吃ai千克肉,并且当天肉的价格是pi,问N天后他至少需要花费多少钱买肉。
分析:注意一下,他是可以提前买好肉放着的。
代码如下:
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std; const int MAXN = ;
const int oo = 1e9+; int main()
{
int N; while(scanf("%d", &N) != EOF)
{
int ai, pi, ans=, MinP=oo; while(N--)
{
scanf("%d%d", &ai, &pi);
MinP = min(MinP, pi);
ans += ai * MinP;
} printf("%d\n", ans);
} return ;
}
Duff and Meat - CF 588A的更多相关文章
- 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/probl ...
- A. Duff and Meat
A. Duff and Meat time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Codeforce 588A - Duff and Meat (贪心)
Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day ...
- Duff and Meat(贪心)
Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day ...
- Codeforces Round #326 (Div. 2)-Duff and Meat
题意: Duff每天要吃ai千克肉,这天肉的价格为pi(这天可以买好多好多肉),现在给你一个数值n为Duff吃肉的天数,求出用最少的钱满足Duff的条件. 思路: 只要判断相邻两天中,今天的总花费 = ...
- 题解 CF588A 【Duff and Meat】
题意 有一个人,想吃 $n$ 天肉,第 $i$ 天需要吃 $a[i]$ 块肉,第 $i$ 天超市肉价为每块 $b[i]$ 元,买来的肉可以留到后面吃,求这个人在每天都吃到肉的情况下花费的最小值. 题目 ...
- 省钱加油(Fuel Economy)题解
题目 农夫约翰决定去做一个环游国家旅行,为了不让他的奶牛们感到孤单,于是他决定租一辆货车带领他的奶牛们一起去旅行.这辆货车的油箱最多可以承载G 个单位的油,同时为了简化问题,规定每一个单位的油可以行使 ...
- CF数据结构练习
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
随机推荐
- Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法 转
Java调用.Net WebService参数为空解决办法 (远程)调试webservice方法 同事遇到一个很囧的问题,java调,netwebservice的时候,调用无参数方法成功,调用有参 ...
- 跨线程操作UI控件
写程序的时候经常会遇到跨线程访问控件的问题,看到不少人去设置Control.CheckForIllegalCrossThreadCalls = false;这句话是告诉编译器不要对跨线程访问作检查,可 ...
- hdu-A+B问题,大数加法
格式问题很头疼啊 Input The first line of the input contains an integer T(1<=T<=20) which means the num ...
- C#中判断bool 类型 代码的最短写法
看到一个关于写最短代码的, 是一个bool类型判断的: public bool IsNull(object val) { if (val == null) { return true; } e ...
- ubuntu下SVN服务器安装配置
SVN服务器端: 1.安装包 $ sudo apt-get install subversion 2.添加svn管理用户及subversion组 $ sudo adduser svnuser $ su ...
- Js处理数据——前端分页工具
这几天有小伙伴讨论起了分页的相关问题,这里我也简单讲下前端如何简单便捷的利用Js(库)写出优雅,好用的分页工具. 分页是个很简单又超多接触的技术点,粗略来讲分如下两种: 真分页--每次根据页码.页大小 ...
- LinkedHasMap实现原理
转载:http://blog.csdn.net/luanlouis/article/details/43017071 Map作为键值对Entry<K,V>的的容器,对其内部 键值对Entr ...
- webservice 的权限验证
1. http://blog.csdn.net/jaune161/article/details/25602655 2. http://wcp88888888.iteye.com/blog/13993 ...
- bzoj 2706: [SDOI2012]棋盘覆盖 Dancing Link
2706: [SDOI2012]棋盘覆盖 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 255 Solved: 77[Submit][Status] ...
- QLGame 2D Engine编写环境搭建
QLGame 2D Engine编写 (win7环境搭建) 广州麒麟网络工作室,计划制作一款2d game engine,基于opengl(es)平台,暂时支持android,以后考虑支持linux, ...