题解 CF588A 【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 aikilo…
A. Duff and Meat time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output 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 exact…
题意 有一个人,想吃 $n$ 天肉,第 $i$ 天需要吃 $a[i]$ 块肉,第 $i$ 天超市肉价为每块 $b[i]$ 元,买来的肉可以留到后面吃,求这个人在每天都吃到肉的情况下花费的最小值. 题目标签:贪心 思路 一边输入一边计算,每次记录下最低价格,即 $mini=min(mini,b[i])$ 然后乘以每天所需要的肉的数量.即 $ans+=mini\times a[i]$ . 代码段: 比较容易实现 for(int i=0;i<n;i++) { cin>>a[i]>>…
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 ai kilograms of meat. There is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, they sell mea…
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 ai kilograms of meat. There is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, they sell mea…
题意: Duff每天要吃ai千克肉,这天肉的价格为pi(这天可以买好多好多肉),现在给你一个数值n为Duff吃肉的天数,求出用最少的钱满足Duff的条件. 思路: 只要判断相邻两天中,今天的总花费 = ai*pi 与昨天的总花费(还有加上今天要吃的肉的重量)= (ai-1 + ai)*pi-1 . 代码如下: #include <iostream> #include <cstdio> #include <cstring> #include <fstream>…
题目大意:有一个人他有每天需要吃ai千克肉,并且当天肉的价格是pi,问N天后他至少需要花费多少钱买肉. 分析:注意一下,他是可以提前买好肉放着的. 代码如下: #include<iostream> #include<string.h> #include<stdio.h> #include<algorithm> #include<math.h> using namespace std; ; ; int main() { int N; while(s…
题目 农夫约翰决定去做一个环游国家旅行,为了不让他的奶牛们感到孤单,于是他决定租一辆货车带领他的奶牛们一起去旅行.这辆货车的油箱最多可以承载G 个单位的油,同时为了简化问题,规定每一个单位的油可以行使一个单位的距离.约翰从起点出发到终点总共要经过D 个单位的距离.约翰知道自己很有可能要在中途的过程中加几次油.他将中途的N 个加油站(加油站看成是排成一条直线的)的位置都记录下来了.对于每一个加油站,他记录了这个加油站到起点的距离Xi,同时也记录了这个加油站的每个单位的油价Yi. 问题描述: 给定以…
//   B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive int…
D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/problem/D Description While Duff was resting in the beach, she accidentally found a strange array b0, b1, ..., bl - 1 consisting of l positive integers. Th…