Problem N
Description
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) cents to produce one unit of yogurt in week i.
Yucky's factory, being well-designed, can produce arbitrarily many
units of yogurt each week.
Yucky Yogurt owns a warehouse that can store unused yogurt at a
constant fee of S (1 <= S <= 100) cents per unit of yogurt
per week. Fortuitously, yogurt does not spoil. Yucky Yogurt's
warehouse is enormous, so it can hold arbitrarily many units of
yogurt.
Yucky wants to find a way to make weekly deliveries of Y_i (0 <=
Y_i <= 10,000) units of yogurt to its clientele (Y_i is the
delivery quantity in week i). Help Yucky minimize its costs over
the entire N-week period. Yogurt produced in week i, as well as any
yogurt already in storage, can be used to meet Yucky's demand for
that week.
integers, N and S.< br>< br>* Lines 2..N+1: Line i+1
contains two space-separated integers: C_i and Y_i.
integer: the minimum total cost to satisfy the yogurt schedule.
Note that the total might be too large for a 32-bit integer.
200
400
300
500
#include
#define maxn 10000
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
int
n,s,c[maxn],y[maxn];
long long
money=0,daymoney=0;
while(scanf("%d%d",&n,&s)!=EOF)
{
money=daymoney=0;
for(int i=0;i
scanf("%d%d",&c[i],&y[i]);
money=c[0]*y[0];
for(int i=1;i
{
daymoney=min(c[i]*y[i],(c[i-1]+s)*y[i]);
//printf("c[i]=%d (c[i-1]+s)=%d\n",c[i],(c[i-1]+s));
//printf("daymoney=%d\n",daymoney);
money+=daymoney;
}
printf("%lld\n",money);
}
}
Problem N的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- MySQL基本语法(一):和SQL Server语法的差异小归纳
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- PyTorch教程之Autograd
在PyTorch中,autograd是所有神经网络的核心内容,为Tensor所有操作提供自动求导方法. 它是一个按运行方式定义的框架,这意味着backprop是由代码的运行方式定义的. 一.Varia ...
- Longge's problem poj2480 欧拉函数,gcd
Longge's problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6918 Accepted: 2234 ...
- windows下怎么解决Python双版本问题
相信大家会在windows下会遇到Python双版本问题 当我们装了Python2和Python3时我们好只能在命令栏调出最高版本的那个低版本的难道消失了吗?今天我们就解决这个问题! 1.下载 我们在 ...
- 史上前端面试最全知识点(附答案)---html & js & css
史上前端面试最全知识点(附答案) 一.html & js & css 1.AMD和CMD是什么?它们的区别有哪些? AMD和CMD是二种模块定义规范.现在都使用模块化编程,AMD,异步 ...
- 【vue系列之二】详解vue-cli 2.0配置文件
上次给大家分享的是用vue-cli快速搭建vue项目,虽然很省时间和精力,但想要真正搞明白,我们还需要对其原理一探究竟. 大家拿到一个项目,要快速上手,正确的思路是这样的: 首先,如果在项目有read ...
- python的urlparse
urlparse主要是URL的分解和拼接,分析出URL中的各项参数,可以被其他的URL使用. 主要的函数有: 1.urlparse 将URL分解为6个片段,返回一个元组,包括协议.基地址.相对地址等等 ...
- python 多进程间交换信息与共享信息
多线程调用函数,获取其返回值,个人总结了三种方法: 一.Queue(进程队列) 构造方法:multiprocessing.Queue([maxsize]) Queue.Queue类即是一个队列的同步实 ...
- 实战之elasticsearch集群及filebeat server和logstash server
author:JevonWei 版权声明:原创作品 实战之elasticsearch集群及filebeat server和logstash server 环境 elasticsearch集群节点环境为 ...
- Echarts数据可视化series-heatmap热力图,开发全解+完美注释
全栈工程师开发手册 (作者:栾鹏) Echarts数据可视化开发代码注释全解 Echarts数据可视化开发参数配置全解 6大公共组件详解(点击进入): title详解. tooltip详解.toolb ...