题意:从小到大给出额定功率,给出该功率费用,和灯泡的数量和单价,现在灯泡能在比他额定功率大的功率运行,求让所有灯泡正常工作的最小费用

分析:

问题转化为求用哪几个功率运行灯泡最小费用,dp[i]前i个功率的灯泡正常最小费用dp[i]=min(dp[i],dp[j]+num)(j<i);

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <complex>
#include <cassert>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
#define lson l,m,rt<<1
#define pi acos(-1.0)
#define rson m+1,r,rt<<11
#define All 1,N,1
#define read freopen("in.txt", "r", stdin)
const ll INFll = 0x3f3f3f3f3f3f3f3fLL;
const int INF= 0x7ffffff;
const int mod = ;
struct node{
int p,k,c,l;
}d[];
int sum[];
bool cmp(node x,node y){
return x.p<y.p;
}
int dp[],n;
void solve(){
sort(d+,d+n+,cmp);
memset(sum,,sizeof(sum));
sum[]=;
for(int i=;i<=n;++i)
sum[i]=sum[i-]+d[i].l;
for(int i=;i<=n;++i)
dp[i]=d[i].c*sum[i]+d[i].k;
for(int i=;i<=n;++i)
{
for(int j=;j<i;++j)
dp[i]=min(dp[i],dp[j]+(sum[i]-sum[j])*d[i].c+d[i].k);
}
printf("%d\n",dp[n]);
}
int main()
{
while(~scanf("%d",&n)){
if(n==)break;
for(int i=;i<=n;++i){
scanf("%d%d%d%d",&d[i].p,&d[i].k,&d[i].c,&d[i].l);
}
solve();
}
return ;
}

Lighting System Design的更多相关文章

  1. 【线性结构上的动态规划】UVa 11400 - Lighting System Design

    Problem F Lighting System Design Input: Standard Input Output: Standard Output You are given the tas ...

  2. (动态规划)UVA-11400:Lighting System Design

    You are given the task to design a lighting system for a huge conference hall. After doing a lot of ...

  3. UVa 11400 Lighting System Design(DP 照明设计)

    意甲冠军  地方照明系统设计  总共需要n不同类型的灯泡  然后进入 每个灯电压v  相应电压电源的价格k  每一个灯泡的价格c   须要这样的灯泡的数量l   电压低的灯泡能够用电压高的灯泡替换   ...

  4. UVA - 11400 Lighting System Design

    题文: You are given the task to design a lighting system for a huge conference hall. After doing a lot ...

  5. UVA11400 Lighting System Design(DP)

    You are given the task to design a lighting system for a huge conference hall. After doing a lot of ...

  6. UVa 11400 Lighting System Design

    题意: 一共有n种灯泡,不同种类的灯泡必须用不同种电源,但同一种灯泡可以用同一种电源.每种灯泡有四个参数: 电压值V.电源费用K.每个灯泡的费用C.所需该种灯泡的数量L 为了省钱,可以用电压高的灯泡来 ...

  7. UVa 11400 Lighting System Design【DP】

    题意:给出n种灯泡,分别给出它们的电压v,电源费用k,每个灯泡的费用c,和所需灯泡的数量l,问最优方案的费用 看的紫书= = 首先是dp[i]为灯泡1到i的最小费用, dp[i]=min(dp[i], ...

  8. uva 11400 Problem F Lighting System Design

    紫皮书题: 题意:让你设计照明系统,给你n种灯泡,每种灯泡有所需电压,电源,每个灯泡的费用,以及每个灯泡所需的数量.每种灯泡所需的电源都是不同的,其中电压大的灯泡可以替换电压小的灯泡,要求求出最小费用 ...

  9. UVA - 11400 Lighting System Design (区间DP)

    这个问题有两个点需要注意: 1. 对于一种灯泡,要么全换,要么全不换. 证明: 设一种灯泡单价为p1,电池价格为k1,共需要L个,若把L1个灯泡换成单价为p2,电池为k2的灯泡,产生的总花费为p1*L ...

随机推荐

  1. DJANGO的requirements的运用

    这里记录一下我现在项目的requirements.pip文件,安装命令为: pip install -r requirements.pip 这样一来,所有依赖,全部搞定. Django== djang ...

  2. 关于Python的super用法

    Python中对象方法的定义很怪异,第一个参数一般都命名为self(相当于其它语言的this),用于传递对象本身,而在调用的时候则不必显式传递,系统会自动传递. 举一个很常见的例子: >> ...

  3. 深入浅出Java并发包—原子类操作

    我们知道,JDK1.5以后引入了并发包(java.util.concurrent)用于解决多CPU时代的并发问题,而并发包中的类大部分是基于Queue的并发类,Queue在大多数情况下使用了原子类(A ...

  4. java:抽象类和抽象函数

    面向对象:先抽象后具体 抽象类也叫基类 抽象函数:只有函数的定义,没有函数体的函数, 语法:类必须定义为抽象类,才能调用抽象函数,抽象类里面可以没有抽象函数 abstract class Printe ...

  5. asp.net(C#)读取word 文档的方法

    第一种方法 Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/msw ...

  6. java使用正则表达式验证IP V4、 IP V6

    package cn.outofmemory.snippets.core; import java.util.regex.Pattern; /** * A collection of utilitie ...

  7. bootstrap 3.x笔记

    布局容器 Bootstrap 需要为页面内容和栅格系统包裹一个 .container 容器.我们提供了两个作此用处的类.注意,由于 padding等属性的原因,这两种 容器类不能互相嵌套. .cont ...

  8. AndroidJNI 调用JAVA(转)

    转自:http://www.cnblogs.com/likwo/archive/2012/05/21/2512400.html   1. JNIEnv对象    对于本地函数    JNIEXPORT ...

  9. ubuntu set host name

    http://wiki.joyent.com/wiki/display/jpc2/Setting+the+Host+Name+on+a+Linux+VM Set the host name in th ...

  10. struct hw_module_t HAL_MODULE_INFO_SYM

    先开个头,准备这与一篇struct hw_module_t HAL_MODULE_INFO_SYM 相关的文章. Hal层的库文件是怎么被上层调用的?上层调用时的入口(相当于main)又是什么呢?它就 ...