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

分析:

问题转化为求用哪几个功率运行灯泡最小费用,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. hdu2018

    http://acm.hdu.edu.cn/showproblem.php?pid=2018 #include<iostream> #include<stdio.h> #inc ...

  2. 1829 A Bug's Life

    A Bug's Life Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  3. lintcode:合并区间

    题目: 合并区间 给出若干闭合区间,合并所有重叠的部分. 样例 给出的区间列表 => 合并后的区间列表: [ [ [1, 3], [1, 6], [2, 6], => [8, 10], [ ...

  4. C++ Primer笔记整理

    1. 迭代器:迭代器是一种对象,它可以看做是游标,用来遍历标准模板库中的部分或者全部元素. 每个迭代器指向容器中确定的地址,此外,迭代器还提供一些基本操作符:*.++.==.!=.=. 2. 模板:是 ...

  5. 在C#中怎么调用Resources文件中的图片

    譬如资源中有名为myPic的图片,在代码中可以这么使用: this.BackgroundImage = Properties.Resources.myPic; 如有疑问,继续追问.

  6. 44. Wildcard Matching

    题目: Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single charact ...

  7. Map.putAll方法——追加另一个Map对象到当前Map集合(转)

    该方法用来追加另一个Map对象到当前Map集合对象,它会把另一个Map集合对象中的所有内容添加到当前Map集合对象. 语法  putAll(Map<? extends K,? extends V ...

  8. LA 6042 Bee Tower 记忆化搜索

    一开始读漏了很多细节,用递推写死活跑不出样例. 把题目中的细节列一下吧,状态方程很好推,改成记忆化搜索之后代码也很清晰. 1.蜜蜂需要到最高的塔去,最高的塔可能不止一个,抵达任意一个即可. 2.蜜蜂每 ...

  9. 【原创】30分钟入门 github

    很久没更新了,这篇文章重点在github的入门使用,读者可以下载github for windows shell,边看边操作,加深印象. 好了,30分钟的愉快之旅开始吧: 一.github使用的注意事 ...

  10. Linux进程调度和切换过程分析

    内容: (1):从schedule()开始,几种不同类型的进程之间的调度选择;在相同类型的进程之间的调度选择算法 (2):从CPU的IP值的变化上,说明在switch_to宏执行后,执行分析 (3): ...