POJ - 2393Yogurt factory
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
cost to satisfy the yogurt schedule. Note that the total might be too
large for a 32-bit integer.
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 <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#define ll long long
#define MAXN 50010
using namespace std;
int cost[MAXN],mai[MAXN];
int n,s;
ll ans=;
int main()
{
scanf("%d%d",&n,&s);
for(int i=;i<=n;i++){
scanf("%d%d",&cost[i],&mai[i]);
}
for(int wek=;wek<=n;wek++){
int minn=<<;
for(int i=;i<=wek;i++){
minn=min(minn,cost[i]+s*(wek-i));
}
ans+=minn*mai[wek];
}
printf("%lld",ans);
return ;
}
POJ - 2393Yogurt factory的更多相关文章
- POJ Widget Factory 【求解模线性方程】
传送门:http://poj.org/problem?id=2947 Widget Factory Time Limit: 7000MS Memory Limit: 65536K Total Su ...
- POJ 2947-Widget Factory(高斯消元解同余方程式)
题目地址:id=2947">POJ 2947 题意:N种物品.M条记录,接写来M行,每行有K.Start,End,表述从星期Start到星期End,做了K件物品.接下来的K个数为物品的 ...
- poj 2393 Yogurt factory
http://poj.org/problem?id=2393 Yogurt factory Time Limit: 1000MS Memory Limit: 65536K Total Submis ...
- POJ 3436 ACM Computer Factory (网络流,最大流)
POJ 3436 ACM Computer Factory (网络流,最大流) Description As you know, all the computers used for ACM cont ...
- 【POJ】2947 Widget Factory(高斯消元)
http://poj.org/problem?id=2947 各种逗啊..还好1a了.. 题意我就不说了,百度一大把. 转换为mod的方程组,即 (x[1,1]*a[1])+(x[1,2]*a[2]) ...
- Poj 3436 ACM Computer Factory (最大流)
题目链接: Poj 3436 ACM Computer Factory 题目描述: n个工厂,每个工厂能把电脑s态转化为d态,每个电脑有p个部件,问整个工厂系统在每个小时内最多能加工多少台电脑? 解题 ...
- A - ACM Computer Factory POJ - 3436 网络流
A - ACM Computer Factory POJ - 3436 As you know, all the computers used for ACM contests must be ide ...
- POJ 3436:ACM Computer Factory(最大流记录路径)
http://poj.org/problem?id=3436 题意:题意很难懂.给出P N.接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2* ...
- POJ 3464 ACM Computer Factory
ACM Computer Factory Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4829 Accepted: 1641 ...
随机推荐
- 增强学习Q-learning分析与演示(入门)
一些说明.参阅 https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow/blob/master/contents/1_ ...
- Maven学习归纳(二)——几个常用命令解析
Maven的常用命令 第一次执行命令的时候,因为需要下载执行命令的基础环境,所以会从远程仓库下载该环境到本地仓库中 运行mvn命令,必须在pom.xml文件所在的目录 一. JavaProject的p ...
- Java线程常见面试题
v 多线程实现手段: (1).继承Thread类 (2)实现Runable接口 (3)使用线程池 v 线程控制在那个包:java.util.concurrent. (1)提供了线程的运行.(2)线程池 ...
- 使用DevExpress的PdfViewer实现PDF打开、预览、另存为、打印(附源码下载)
场景 Winform控件-DevExpress18下载安装注册以及在VS中使用: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/1 ...
- application.properties 乱码 (已验证)
1.打开Eclipse或MyEclipse 2.选择window-Preferences-content Types-Text-Java Properties File 3.将Java Propert ...
- ZK Watcher 的原理和实现
什么是 ZK Watcher 基于 ZK 的应用程序的一个常见需求是需要知道 ZK 集合的状态.为了达到这个目的,一种方法是 ZK 客户端定时轮询 ZK 集合,检查系统状态是否发生了变化.然而,轮询并 ...
- 关于CPU核心,线程,进程,并发,并行,及java线程之间的关系
前言:作为一个转行java的小白,一直搞不清楚java中的多线程.于是来梳理一下关于CPU核心,线程,进程,并发,并行,及java线程之间的关系, 1.CPU角度来看: 我们以Intel的Core i ...
- Oracle内置函数之数值型函数
think different
- Flink cep的初步使用
一.CEP是什么 在应用系统中,总会发生这样或那样的事件,有些事件是用户触发的,有些事件是系统触发的,有些可能是第三方触发的,但它们都可以被看做系统中可观察的状态改变,例如用户登陆应用失败.用户下了一 ...
- [Scikit-learn] 4.3 Preprocessing data
数据分析的重难点,就这么来了,欢迎欢迎,热烈欢迎. 4. Dataset transformations 4.3. Preprocessing data 4.3.1. Standardization, ...