Problem Description
The cows have purchased a yogurt factory that makes world-famousYucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, theprice of milk and labor will fluctuate weekly such that it willcost the company C_i (1 <= C_i <= 5,000) cents to produce oneunit of yogurt in week i. Yucky's factory, being well-designed, canproduce arbitrarily many units of yogurt each week.
Yucky Yogurt owns a warehouse that can store unused yogurt at aconstant fee of S (1 <= S <= 100) cents per unit of yogurtper week. Fortuitously, yogurt does not spoil. Yucky Yogurt'swarehouse is enormous, so it can hold arbitrarily many units ofyogurt.
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 isthe delivery quantity in week i). Help Yucky minimize its costsover the entire N-week period. Yogurt produced in week i, as wellas any yogurt already in storage, can be used to meet Yucky'sdemand for that week.
Input
* Line 1: Two space-separated integers, N and S.
* Lines 2..N+1: Line i+1 contains two space-separated integers: C_iand Y_i.
Output
* Line 1: Line 1 contains a single integer: the minimum totalcost to satisfy the yogurt schedule. Note that the total might betoo large for a 32-bit integer.
Sample Input
4 5
88 200
89 400
97 300
91 500
Sample Output
126900
题目大意:
输入数据包含每天生产酸奶的价格和需要的数量,当天的需求可以当天生产,也可以用之前剩下的,每保存一天酸奶,每单位话费 样例中的 5。求最小花费。
思路:
每次生产时比较当天的价格和之前的价格(加上保存到现在的花费),取小的就行啦。
感想:
大半夜写的,困死了。。
AC代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
}