看到n范围和给的区间看着就像区间dp 然后怎么cmp感觉都没法进行区间合并

n的300误导了下 没有注意离散化之后对时间可以dp

然而这个dp感觉不太经得起证明的样子...

dp[i][j] -> 把完全包含在[i,j]里面的区间打完的cost

那么枚举裂缝 需要加上的是 跨越裂缝的区间的cost 这个没办法做

可以知道 如果有两个完全不相交的区间 它们肯定会分在裂缝的两边 所以不用管

所以我们只需要考虑那些 完全连接在一起的区间 选择最贵的一个打掉

而裂缝肯定在最贵的[l,r]里面

* 1 区间离散化不影响做题

* 2 不一定非要泛用决战型枚举裂缝

int a[305] , b[305] , c[305] ;
int dp[605][605] ;
int main () {
int t = read() ;
while(t -- ) {
flc(dp,0) ;
int n = read() ;
vector<int> e ;
rep(i,1,n) {
a[i]=read(),b[i]=read(),c[i]=read();
e.pb(a[i]) , e.pb(b[i]) ;
}
sort(e.begin(),e.end()) ;
e.erase(unique(e.begin(),e.end()),e.end()) ;
rep(i,1,n) {
a[i] = lower_bound(e.begin(),e.end(),a[i])-e.begin()+1 ;
b[i] = lower_bound(e.begin(),e.end(),b[i])-e.begin()+1 ;
}
int m = e.size();
rep(len,2,m) {
rep(i,1,m){
int j=i+len-1;
if(j>m)break ;
int C = -1 ;
int l = -1 , r = -1 ;
rep(k,1,n) {
if(a[k] >= i && b[k] <= j) {
if(C < c[k]) {
l = a[k] , r = b[k] ; C = c[k] ;
}
}
}
if(l == -1) {
dp[i][j] = 0 ;
}
else {
dp[i][j] = 999999999 ;
rep(k,l,r) {
dp[i][j] = min(dp[i][j] , dp[i][k-1] + dp[k+1][j] + C) ;
}
}
}
}
printf("%d\n" , dp[1][m]) ;
}
}

uvalive 6938 区间dp的更多相关文章

  1. UVALive - 7061 区间DP初步

    题意:杀一只狼i会收到a[i]+b[i当前左边]+b[i当前右边]的攻击,求杀死所有狼的最小代价 #include<iostream> #include<algorithm> ...

  2. UVALive 4987---Evacuation Plan(区间DP)

    题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  3. 【BZOJ-4380】Myjnie 区间DP

    4380: [POI2015]Myjnie Time Limit: 40 Sec  Memory Limit: 256 MBSec  Special JudgeSubmit: 162  Solved: ...

  4. 【POJ-1390】Blocks 区间DP

    Blocks Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5252   Accepted: 2165 Descriptio ...

  5. 区间DP LightOJ 1422 Halloween Costumes

    http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...

  6. BZOJ1055: [HAOI2008]玩具取名[区间DP]

    1055: [HAOI2008]玩具取名 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1588  Solved: 925[Submit][Statu ...

  7. poj2955 Brackets (区间dp)

    题目链接:http://poj.org/problem?id=2955 题意:给定字符串 求括号匹配最多时的子串长度. 区间dp,状态转移方程: dp[i][j]=max ( dp[i][j] , 2 ...

  8. HDU5900 QSC and Master(区间DP + 最小费用最大流)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5900 Description Every school has some legends, ...

  9. BZOJ 1260&UVa 4394 区间DP

    题意: 给一段字符串成段染色,问染成目标串最少次数. SOL: 区间DP... DP[i][j]表示从i染到j最小代价 转移:dp[i][j]=min(dp[i][j],dp[i+1][k]+dp[k ...

随机推荐

  1. Win7 sql2005附加数据库失败 错误5120

      错误信息如下: 标题: Microsoft SQL Server Management Studio Express------------------------------ 附加数据库 对于 ...

  2. 巨蟒django之CRM3 添加和编辑客户&&公户和私户的展示和转换

    昨日内容回顾: day66 1. 内容回顾 1. 数据的展示 数据通过ORM查询出来 对象列表 QuerySet 1. 普通的字段 对象.字段名 ——> 数据库中的值 2. choices (( ...

  3. geometric mean

    w

  4. sqlbulk的问题

    今天在bulk的时候遇到一个很“奇怪”的问题 无论怎样修改传入的值,也会报类型转换的错误.后来 在此文中找到了正解 bbs.csdn.net/topics/390430064 SqlBulkCopy不 ...

  5. 解决CSS3多列样式column-width布局时内容被截断、错乱

    一.问题 使用CSS3的column-width: auto | <length>属性时,出现排列的内容被截断,出现错位的现象. 二.原因 需要为图片容器设置高度,不然会崩掉. 三.解决方 ...

  6. 在VM虚拟机中安装Centos7操作系统(三)

    首先我们要下载  Centos https://www.centos.org/ 这个是Centos官方 最新版本 7 https://www.centos.org/download/ 提供有 DVD安 ...

  7. Apache JServ Protocol (AJP)

    The Apache JServ Protocol (AJP) is a binary protocol that can proxy inbound requests from a web serv ...

  8. CSS让一个元素一闪一闪的

    .heart{ animation:heart 1s ease infinite; } @keyframes heart { 0% {opacity:0.1;} 100%{;} }

  9. Python基础-os和sys模块

    os模块提供对操作系统进行调用的接口 import os os.getcwd() # 获取当前工作目录 os.chdir(r'd:\fansik') # 修改对当前工作目录 print(os.curd ...

  10. iOS Application Project与OS X Application Project对于plist使用的区别

    前几天因为在开源中国看到一个求源代码的问题: 模拟一个动物园系统MyZoo 1.动物园里面有三种动物:Panda,Elephant,Kangaroo 2.三种动物都有一定的数量(不止一只) 3.动物有 ...