Gym - 100543L
Gym - 100543L
https://vjudge.net/problem/153854/origin
区间dp,要从区间长度为1开始dp
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 1010
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
long long T;
long long n,m;
struct node{
long long l;
long long r;
long long w;
}a[N];
long long b[N],id,Max;
long long f[N][N];
void in(long long &x){
long long y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(long long x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
} void clear(){
m=;
//memset(f,0,sizeof(f));
} int main(){
in(T);
while(T--){
clear();
in(n);
For(i,,n){
in(a[i].l);in(a[i].r);in(a[i].w);
b[++m]=a[i].l;
b[++m]=a[i].r;
}
sort(b+,b+m+);
m=unique(b+,b+m+)-b-;
For(i,,n){
a[i].l=lower_bound(b+,b+m+,a[i].l)-b;
a[i].r=lower_bound(b+,b+m+,a[i].r)-b;
}
For(len,,m)
For(l,,m-len+){
int r=l+len-;
id=;
For(i,,n)
if(a[i].l>=l&&a[i].r<=r)
if(id==||a[i].w>a[id].w)
id=i;
if(id==){
f[l][r]=;
continue;
}
f[l][r]=inf;
For(i,a[id].l,a[id].r)
f[l][r]=min(f[l][r],f[l][i-]+f[i+][r]+a[id].w);
}
o(f[][m]);p('\n');
}
return ;
}

Gym - 100543L的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- EF 如何更新多对多关系的实体
ctx.Entry(user).Collection(t => t.UserPrivileges).Load(); Come form:https://www.thereformedprogra ...
- Idea中创建maven骨架的命令
如下:通过命令化在Idea中创建骨架成功后,以后项目直接引用导入骨架直接在依赖框架上面进行相关模块开发: 1.mvn archetype:create-from-project 2.mvn clean ...
- java 自加和短路问题 几个例子
x++可以看做一个独立的变量 如int a=x++;x的值先把他赋值给x++然后X++再赋值a,最后x再自加1 ++X int a=++ X 先自加1 x的值赋值给++x然后++x再赋值a ...
- Windows tasklist
TASKLIST [/S system [/U username [/P [password]]]] [/M [module] | /SVC | /V] [/FI filter] [/ ...
- thinkphp 使用php代码
Php代码可以和标签在模板文件中混合使用,可以在模板文件里面书写任意的PHP语句代码 ,包括下面两种方式: 直线电机选购 第一种:使用php标签 例如: <php>echo 'Hello, ...
- 莫比乌斯反演——hdu6390推公式
/*首先要把原始化简成 k/phi[k] 的格式,然后把有关k的sigma提出来,后面就是求gcd(i,j)==k的莫比乌斯反演这里要用整除分块加下速*/#include<bits/stdc++ ...
- How to Hide Apache Tomcat Version Number from Error Pages
1. 进入tomcat lib目录 cd /usr/local/tomcat7/lib 2. 解压catalina.jar jar xvf catalina.jar 3. 修改ServerInfo.p ...
- 愚人节老板发话了,免费送书 + 免费入驻Java知识星球!!
愚人节快乐,今天的活动很重磅! 1.免费送5本重量级技术书籍,不骗人,小程序随机抽奖送出哦! 2.免费进星球,哈哈不可能,愚人节快乐!不过今天有重大优惠,见下文! 活动一:免费送出5本重量级书籍 赠书 ...
- 16.ajax_case06
# 抓取华尔街见闻实时快讯 # https://wallstreetcn.com/live/global?from=navbar import requests import json header ...
- [POI2013]MOR-Tales of seafaring
题目 思博题,发现一旦路径太长我们可以来回走最后一条边,但是这样并不能改变路径长度的奇偶性 所以求一下所有点之间奇最短路和偶最短路就好了,直接暴力\(BFS\)即可 有一个烦人的特判 代码 #incl ...