题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1680 题意: 在接下来的n周内,第i周生产一吨酸奶的成本为c[i],订单为y[i]吨酸奶. 酸奶可以提前生产,可以存放无限长的时间,存放一周的花费为s. 问你在完成所有订单的前提下,最小的花费为多少. 题解: 贪心. p[i]代表第i周的最小成本. 对于p[i],只用考虑p[i-1],因为已经保证了p[i-1]是i-1之前所有周的最优答案. 所以转移为:p[i] = min(c[i],…
贪心,一边读入一边更新mn,用mn更新答案,mn每次加s #include<iostream> #include<cstdio> using namespace std; int n,s,mn=1e9; long long ans; int main() { scanf("%d%d",&n,&s); for(int i=1,w,c;i<=n;i++) { scanf("%d%d",&w,&c); mn+=…
http://www.lydsy.com/JudgeOnline/problem.php?id=1680 看不懂英文.. 题意是有n天,第i天生产的费用是c[i],要生产y[i]个产品,可以用当天的也可以用以前的(多生产的).每单位产品保存一天的费用是s.求最小费用 显然贪心,每次查找之前有没有哪一天保存到现在的价值最小,然后比较更新.. #include <cstdio> #include <cstring> #include <cmath> #include <…
Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it will cost the company C_i (1 <= C_i <= 5,000) c…
1680: [Usaco2005 Mar]Yogurt factory Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 106  Solved: 74[Submit][Status][Discuss] Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000)…
1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 119  Solved: 100[Submit][Status][Discuss] Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10…
bzoj1680[Usaco2005 Mar]Yogurt factory bzoj1740[Usaco2005 mar]Yogurt factory 奶酪工厂 题意: n个月,每月有一个酸奶需求量(吨)和酸奶成本(元每吨).酸奶可以保存,费用为S(元每月每吨),求最小总费用.n≤10000 题解: 第i月每吨酸奶的成本为Cj+s*(i-j),j∈[1,i],化简得Cj-s*j+s*i,因为s*i只和当前相关,所以维护一个最小的Cj-s*j即可.注意开long long. 代码: #includ…
n<=10000天每天Ci块生产一东西,S块保存一天,每天要交Yi件东西,求最少花多少钱. 这个我都不知道归哪类了.. #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> //#include<iostream> using namespace std; int n,m; #define maxn 10011 int a,b; #define…
接下来的N(1≤N10000)星期中,奶酪工厂在第i个星期要花C_i分来生产一个单位的奶酪.约克奶酪工厂拥有一个无限大的仓库,每个星期生产的多余的奶酪都会放在这里.而且每个星期存放一个单位的奶酪要花费S分.工厂最近收到了客戶N个星期的订单,第i个星期要向客戶提供Y_i 个单位的奶酪.当然这些奶酪可以在第i个星期时生产,也可以从仓库中拿取.采用怎样的生产策略约克奶酪工厂的花费最小呢?Input第一行两个整数:N和S:接下来的N行中,第i行的两个数表示:C_i和Y_i.Output仅一行,即工厂生产…
Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it will cost the company C_i (1 <= C_i <= 5,000) c…