Problem
Description
The cows have purchased a yogurt
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.
Input
* Line 1: Two space-separated
integers, N and S.< br>< br>* Lines 2..N+1: Line i+1
contains two space-separated integers: C_i and Y_i.
Output
* Line 1: Line 1 contains a single
integer: the minimum total 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
题意:这题就是给出第I天生产货物的成本和需要生产的货物数量,并且可生产比需求量更多的数量,但是货物的每天保管费用是5快钱:
思路:就是简单的贪心比较用今天的成本和昨天的成本加上报关费那个便宜,用哪个;
代码:
#include

#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的更多相关文章

  1. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  2. 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 ...

  3. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  4. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit] ...

  8. [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 ...

  9. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  10. PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

    $s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...

随机推荐

  1. NIO通讯框架之Mina

          在两三年前,阿堂在技术博客(http://blog.sina.com.cn/heyitang)上曾经写过"JAVA新I/O学习系列笔记(1)"和"JAVA新I ...

  2. 优秀的CSS预处理----Less

    Less语法整理 本人邮箱:kk306484328@163.com,欢迎交流讨论. 欢迎转载,转载请注明网址:http://www.cnblogs.com/kk-here/p/7601058.html ...

  3. web应用中的异常处理

    楼主前几天写了一篇“Java子线程中的异常处理(通用)”文章,介绍了在多线程环境下3种通用的异常处理方法. 但是平时大家的工作一般是基于开发框架进行的(比如Spring MVC,或Spring Boo ...

  4. 一文为你详细讲解对象映射库【AutoMapper】所支持场景

    前言 在AutoMapper未出世前,对象与对象之间的映射,我们只能通过手动为每个属性一一赋值,时间长了不仅是我们而且老外也觉得映射代码很无聊啊.这个时候老外的所写的强大映射库AutoMapper横空 ...

  5. jvm中的垃圾回收器

    HotSpot JVM收集器 上面有7中收集器,分为两块,上面为新生代收集器,下面是老年代收集器.如果两个收集器之间存在连线,就说明它们可以搭配使用.Serial(串行GC)收集器 Serial收集器 ...

  6. python之爬虫

    一.从网页爬下字符串清除特殊字符 import re def validateTitle(title): rstr = r"[\/\\\:\*\?\"\<\>\|\t] ...

  7. SAP 图标查找及方法

    1. 图标查找 方法一:通过TCODE查找图标对应的图标名称 执行TCODE:ICON 查找图标对应的图标名称 方法二:通过方法一查出图标名称查找对应的图标ID SE11类型池根据方法一查找的ICON ...

  8. zoj 1874 水题,输出格式大坑

    Primary Arithmetic Time Limit: 2 Seconds      Memory Limit: 65536 KB Children are taught to add mult ...

  9. 在C#中实现串口通信的方法

    通常,在C#中实现串口通信,我们有四种方法: 第一:通过MSCOMM控件这是最简单的,最方便的方法.可功能上很难做到控制自如,同时这个控件并不是系统本身所带,所以还得注册,不在本文讨论范围.可以访问h ...

  10. Kvm虚拟化的一种打包及部署方案(采用tar包,lvm方式)

    Kvm虚拟化的一种打包部署方案(采用tar包,lvm方式) –-–-–-2016年终总结 一 毕业之后跟师兄学到的第一块主要内容,理解花了不少时间.期间经历了shell的入门.linux基础知识入门. ...