题目大意:

有一个照明系统需要用到n种灯,每种灯的电压为V,电源费用K,每个灯泡费用为C,需要该灯的数量为L。注意到,电压相同的灯泡只需要共享一个对应的电源即可,还有电压低的灯泡可以被电压高的灯泡替代。为了节约成本,你将设计一种系统,使之最便宜。

/*
好的处理方法是按照电压从小到大排序,只能让前面的换成后面的,也就满足了 把一些灯泡换成电压更高的灯泡 的要求; 一种电压的灯泡,要么不换,要换则应该全换:换,说明用当前的电源不值;而既然不值则应该全部换掉以避免使用当前电源,不然即增加了灯泡费用又没节省电源费用,亏大了。。。
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = ;
struct lamp
{
int v,k,c,l;
}a[maxn];
int n,v1,k1,c1,l1;
int s[maxn];
int d[maxn];
bool cmp(lamp a1,lamp a2){
return a1.v<a2.v;
}
int main(){
while(scanf("%d",&n)!=EOF){
if(n==) break;
memset(s,,sizeof(s));
memset(d,,sizeof(d));
memset(a,,sizeof(a));
for(int i=;i<=n;i++){
scanf("%d%d%d%d",&v1,&k1,&c1,&l1);
a[i].v=v1;
a[i].k=k1;
a[i].c=c1;
a[i].l=l1;
}
sort(a+,a+n+,cmp);
for(int i=;i<=n;i++)s[i]=s[i-]+a[i].l;
for(int i=;i<=n;i++){
for(int j=;j<i;j++){
if(j==)d[i]=(s[i])*a[i].c+a[i].k;
else d[i]=min(d[j]+(s[i]-s[j])*a[i].c+a[i].k,d[i]);
}
}
printf("%d\n",d[n]);
}
return ;
}

uva11400 Lighting System Design的更多相关文章

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

  2. UVa11400 - Lighting System Design——[动态规划]

    题干略. 题意分析: 很容易理解一类灯泡要么全部换要么全不换,其实费用节省的主要原因是由于替换灯泡类型而排除了低压电压源,于是我们就可以推断出灯泡类型替换的原则: 对于两类灯泡a1和a2,a1可以被a ...

  3. 【Uva11400 Lighting System Design】动态规划

    分析 先按照电压从小到大排序,做一下前缀和s[i]求i之前的电灯泡的数量. 状态:$ F_i\(表示到\) i$个灯泡的最小开销. 状态转移方程:$ F_i=F_j+(s[i]-s[j])\times ...

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

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

  5. (动态规划)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 ...

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

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

  7. UVA - 11400 Lighting System Design

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

  8. 【神仙DP】【UVa11400】Lighting System Design

    传送门 Description Translation 题目大意:有一个照明系统需要用到n种灯,每种灯的电压为V,电源费用K,每个灯泡费用为C,需要该灯的数量为L.注意到,电压相同的灯泡只需要共享一个 ...

  9. UVa 11400 Lighting System Design

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

随机推荐

  1. Java for LeetCode 120 Triangle

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  2. Algorithm: inversion

    inversion就是逆序对 题目:现给出一个数列,求该数列中的逆序对数(逆序数).本节给出三种方法:方法一是最直接的暴力方法:方法二是基于归并分治的思想:方法三是基于线段树的.   [解法一] 暴力 ...

  3. 6410开发板sd卡启动时烧写u-boot.bin以及u-boot-spl-16k.bin步骤

    参考文档:<SMDK6410_IROM_APPLICATION NOTE_REV 1.00>(可以从这里下载到> 参考博客:Tekkaman的博文<u-boot-2010.09 ...

  4. 使用python转换编码格式

    之前有写过一个使用powershell转换文档格式的方法,然而因为powershell支持不是很全,所以并不好用.这里使用python再做一个. 思路 检测源码格式,如果不是utf8,则进行转换,否则 ...

  5. Perl 日期时间函数(date time)

    use Time::HiRes qw(time);use POSIX qw(strftime); my $t = time;my $date = strftime "%Y%m%d %H:%M ...

  6. ansible playbook学习

    摘自: http://www.ywnds.com/?p=6064 https://github.com/ansible/ansible-examples

  7. cmake编译成功之后VS2015可以build Solution但是不可以运行的解决办法

    1.在VS2015解决方案管理器中删除掉ALL_BUILD和ZERO_CHECK项,只保留Cmake生成的工程文件. 2.进行第一部之后还是有可能生成(build)失败,此时有可能是缺少文件.

  8. Eclipse_插件_02_jd-eclipse插件的安装

    1.去官网下载 jd-eclipse插件 2.解压后的文件夹A放到eclipse的drops文件夹下 3.删掉多余文件,确保文件夹A下只有plugin 和 freature 两个文件夹 4.清空osg ...

  9. codeforces 558B B. Amr and The Large Array(水题)

    题目链接: B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes in ...

  10. C++ 创建文件的方法

    CString getPath(){ CTime time = CTime::GetCurrentTime(); CString t = time.Format(_T("%Y%m%d%H%M ...