poj2393
来源:互联网 发布:完整性保护算法 编辑:程序博客网 时间:2024/06/03 17:02
题目链接:http://poj.org/problem?id=2393
题意:每周生产酸奶的成本是C_i,生产的数量是Y_i,储存酸奶的成本是s,问最小的成本是多少?
解题思路:每生产完一周之后,就记录下该周生产的单价,到下一周时比较该周的生产单价和之前记录下的生产单价加上储存的费用,从而得出最小的生产价格。
#include <cstdio>#include <algorithm>using namespace std;typedef long long int64;int main() { int n, s; while (scanf("%d %d", &n, &s) == 2) { int64 ans = 0, t; int c, y; for (int i = 0; i < n; i++) { scanf("%d %d", &c, &y); if (i == 0) { t = (int64)c; } else { t = min(t + s, (int64)c); } ans += t * y; } printf("%lld\n", ans); } return 0;}
0 0
- poj2393
- poj2393
- poj2393
- poj2393
- 贪心--poj2393
- poj2393 贪心
- poj2393贪心
- poj2393 Yogurt factory
- POJ2393 Yogurt factory 【贪心】
- POJ2393(贪心)
- POJ2393-Yogurt factory
- poj3190 poj2393 贪心
- poj2393(贪心)
- POJ2393 Yogurt factory(贪心)
- 贪心 poj2393 Yogurt factory
- POJ2393 -- Yogurt factory -- 贪心
- Yogurt factory-POJ2393
- POJ2393 Yogurt factory (贪心)
- Android 仿ios 可滑动切换效果按钮 实例代码
- 关于Switch的自定义样式
- uva 10003 Cutting Sticks (DP)
- 黑马程序员---c语言基础--基本运算
- Parsing Arguments with getopt
- poj2393
- 堆和堆排序
- 选择排序
- poj 2240 floyd
- spring mvc json null空转""空串
- 浅谈oracle数据库索引
- 30个实例详解TOP命令
- 基础练习 数的读法
- 算法训练 区间k大数查询