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

分析:

问题转化为求用哪几个功率运行灯泡最小费用,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-tinymce搞个富文本编辑器

    玩过一圈之后,这些应用慢慢变得简单: 步骤如下: 一,安装: pip install django-tinymce 二,配置APP: INSTALLED_APPS = ( ... 'tinymce', ...

  2. 典型重构3 (Try/Catch)

    Try/Catch 块过多 public Customer GetCustomer(string customerId) { try { var command = new SqlCommand(); ...

  3. 用 EasyBCD 在 Win7/8 中硬盘安装 Ubuntu

    写在前面: 1. 我装的是ubuntu 13.10 64位,不一样的地方是,从casper文件夹复制出来的文件不是vmlinuz,而是vmlinuz.efi,相应的,menu.lst里也要将vmlin ...

  4. python自定义函数在Python解释器中调用

    https://docs.python.org/2.7/tutorial/modules.html Modules If you quit from the Python interpreter an ...

  5. cojs 白树黑 黑树白 题解报告

    黑树白 首先如果不是强制在线,这个题用莫队+树状数组就可以在O(n*sqrt(n)*log(n))的时间内搞定 如果没有修改操作,可以直接上主席树就可以辣 我们考虑修改操作,某一个修改操作对于某一个查 ...

  6. SQL索引一步到位(此文章为“数据库性能优化二:数据库表优化”附属文章之一)

    SQL索引一步到位(此文章为“数据库性能优化二:数据库表优化”附属文章之一) SQL索引在数据库优化中占有一个非常大的比例, 一个好的索引的设计,可以让你的效率提高几十甚至几百倍,在这里将带你一步步揭 ...

  7. JNIEnv解析

    1.关于JNIEnv和JavaVM JNIEnv:线程相关的变量 JavaVM:是虚拟机在JNI层的代表, JNIEnv是一个与线程相关的变量,不同线程的JNIEnv彼此独立.JavaVM是虚拟机在J ...

  8. [POJ3694]Network(LCA, 割边, 桥)

    题目链接:http://poj.org/problem?id=3694 题意:给一张图,每次加一条边,问割边数量. tarjan先找出所有割边,并且记录每个点的父亲和来自于哪一条边,然后询问的时候从两 ...

  9. Altium designer总结

    itwolf原创文章,转载请注明出处 大概有半年没有画过PCB板了,最近突然又要画一个简单的小板子,却发现好多东西已经不是很熟练了,现在把Altium designer软件的使用中要注意的问题和一些小 ...

  10. abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized?

    abstract的method不可以是static的,因为抽象的方法是要被子类实现的,而static与子类扯不上关系! native方法表示该方法要用另外一种依赖平台的编程语言实现的,不存在着被子类实 ...