2393:Yogurt factory 总时间限制:  1000ms 内存限制:  65536kB 描述 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 th…
Yogurt factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6821   Accepted: 3488 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…
https://vjudge.net/problem/POJ-2393 因为仓储费是不变的. 对于每一周,要么用当周生产的,要么接着上一周使用的价格(不一定是输入的)加上固定的仓储费用. 应该算是用到了叠加的想法吧,如果本周使用上一周的价格+s,就相当于加法分配律,左边项委托上一周帮我付到上一周那时刻,然后再加上我这一周的仓储付费和. #include<iostream> #include<cstdio> #include<queue> #include<cstr…
题目链接:https://cn.vjudge.net/problem/POJ-2393 题意 有一个生产酸奶的工厂,还有一个酸奶放在其中不会坏的储存室 每一单元酸奶存放价格为每周s元,在接下来的N周时间里,在第i周生产1单元的酸奶需要花费ci,然后奶牛在第i周会交付顾客yi的酸奶 求最小花费 思路 多生产的酸奶可以放在下周来卖,其实可以看作提前生产下周酸奶的成本会增加s元 维护一个最小的价格即可 代码 #include <cstdio> int main(void){ int n, s; wh…
http://poj.org/problem?id=2393 奶牛们有一个工厂用来生产奶酪,接下来的N周时间里,在第i周生产1 单元的奶酪需要花费ci,同时它们也有一个储存室,奶酪放在那永远不会坏,并且可以无限放,每一单元奶酪放在那的价格恒定为每周s.然后奶牛在第i周会交付顾客yi的奶酪,让你求最小花费. 因为第i周的奶酪,可以在第i周生产,也可以在前几周生产,然后储存.通过把s转化为花费,跟原有花费去比较,取一个最小值,这样从头到尾,每一周都可以取得一个花费的最小值.贪心求解. #includ…
思路: 贪心. 实现: #include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; struct node { ll c, y; }; node a[]; ll n, s; int main() { cin >> n >> s; ; i < n; i++) { scanf("%d %d&q…
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…
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…
http://poj.org/problem?id=2393 Yogurt factory Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7341   Accepted: 3757 Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10…
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)…