Yogurt factory
Description
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.
Input
* Lines 2..N+1: Line i+1 contains two space-separated integers: C_i and Y_i.
Output
Sample Input
4 5
88 200
89 400
97 300
91 500
Sample Output
126900
Hint
In week 1, produce 200 units of yogurt and deliver all of it. In week 2, produce 700 units: deliver 400 units while storing 300 units. In week 3, deliver the 300 units that were stored. In week 4, produce and deliver 500 units.
#include<stdio.h>
struct Yogurt
{
int c;
int y;
};
int main()
{
int n,s,i;
long long ans;
struct Yogurt a[];
a[].c=;
while(scanf("%d%d",&n,&s)!=EOF)
{
for(i=; i<=n; i++)
{
scanf("%d%d",&a[i].c,&a[i].y);
}
for(i=; i<=n; i++)
{
if(a[i].c<a[i-].c+s)
a[i].c=a[i].c;
else
a[i].c=a[i-].c+s;
}
ans=;
for(i=; i<=n; i++)
{
ans=ans+a[i].c*a[i].y;
}
printf("%lld\n",ans);
}
return ;
}
Yogurt factory的更多相关文章
- poj 2393 Yogurt factory
http://poj.org/problem?id=2393 Yogurt factory Time Limit: 1000MS Memory Limit: 65536K Total Submis ...
- BZOJ1680: [Usaco2005 Mar]Yogurt factory
1680: [Usaco2005 Mar]Yogurt factory Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 106 Solved: 74[Su ...
- Yogurt factory(POJ 2393 贪心 or DP)
Yogurt factory Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8205 Accepted: 4197 De ...
- 1740: [Usaco2005 mar]Yogurt factory 奶酪工厂
1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 119 Solved: ...
- POJ 2393 Yogurt factory 贪心
Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the ...
- C - Yogurt factory
The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 &l ...
- 【BZOJ】1680: [Usaco2005 Mar]Yogurt factory(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=1680 看不懂英文.. 题意是有n天,第i天生产的费用是c[i],要生产y[i]个产品,可以用当天的也 ...
- POJ2393 Yogurt factory 【贪心】
Yogurt factory Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6821 Accepted: 3488 De ...
- BZOJ 1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 贪心 + 问题转化
Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the ...
随机推荐
- Navicat 12 连接 Mysql8.0 使用日志
目前最新的Mysql8.0 + Navicat12,使用中常有一些棘手问题 解决了的都会贴出来,受益于小伙伴们 我们的目标是发现问题,解决问题,欢迎大家贴出自己使用时遇到的问题,集思广益 好了,上干货 ...
- 一个简单的Linux启动jar包的shell脚本
背景: 项目设备端需要运行jar包程序与服务端进行socket连接并发送数据,每次启动进程时,都需要在Linux终端输入启动jar包的命令,比较繁琐,随之尝试将启动jar包的命令写入shell脚本文件 ...
- 关于JQuery的异步注册
在采用JQuery进行表单异步提交时,前台传入的是json数据格式,后台controller用map接收,再传回前台进行结果判断时,if-else接收结果()里面,尽量不要出现“=”,不然判断语句失效 ...
- JS中判断字符串中出现次数最多的字符及出现的次数
<script type="text/javascript"> var str = 'qwertyuilo.,mnbvcsarrrrrrrrtyuiop;l,mhgfd ...
- 学习tp5的第三天(模型)
一.模型 1.定义基础模型 <?php namespace app\index\model; use think\Model; class User extends Model{ // 设置完整 ...
- 大数据分析系统Hadoop的13个开源工具
Hadoop是由Apache基金会开发的一个大数据分布式系统基础架构,最早版本是2003年原Yahoo!DougCutting根据Google发布的学术论文研究而来. 用户可以在不了解分布式底层细节的 ...
- 移植ARM linux下远程连接工具dropbear
移植ARM linux下远程连接工具dropbear 原文地址:http://www.cnblogs.com/NickQ/p/9010529.html 移植zlib 下载地址:https://gith ...
- 如何通过SQL语句写入webshell
在web应用场景下,经常会碰到SQL注入场景,如页面能够执行SQL语句,那么可能会有直接通过SQL语句写入webshell的风险,常见的phpmyadmin环境下,通过几个语句可以轻松将一句话木马写入 ...
- SQL SERVER循环遍历(普通循环和游标循环)
1.首先需要一个测试表数据Student 2.普通循环 1)循环5次来修改学生表信息 --循环遍历修改记录--declare @i int set @i=0while @i<5begin ...
- 20155310 2016-2017-2《Java程序设计》课程总结
20155310 2016-2017-2<Java程序设计>课程总结 (按顺序)每周作业链接汇总 预备作业一:对师生关系的看法以及对专业的期望 预备作业二:Learning by doin ...