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 ...
随机推荐
- [JZOJ6340] 【NOIP2019模拟2019.9.4】B
题目 题目大意 给你个非负整数数列\(a\),每次等概率选择大于零的\(a_i\),使其减\(1\). 问\(a_1\)被减到\(0\)的时候期望经过多少次操作. 思考历程 对于这题的暴力做法,显然可 ...
- 登录操作(方法一:设置flag标志位)
登录操作(方法一:设置flag标志位) user_name="star"passwoed='123'passed_authentication=Falsecount=0for i ...
- xml 单例类
MD5JSON.h #pragma once #include "include/json/json.h" #include "include/md5/md5.h&quo ...
- 织梦怎么调用栏目SEO标题
点击[模板][默认模板管理]找到模板文件名[list_article.htm],点击模板后面的修改,弹出修改模板代码页面.更改模板文件中<title>{dede:field.title/} ...
- 概率dp——cf148D
求概率应该dp数组应该顺着求 这是由初始状态来决定递推方向的 /* 盒子里有两种颜色的球,一种是黑色另一种是白色 AB轮流去球,A先取 A每次随机摸一个球 B每次随机摸一个球,然后盒子里再丢一个球 先 ...
- redis可视化客户端工具TreeNMS
TreeNMS是一款redis,Memcache可视化客户端工具,采用JAVA开发,实现基于WEB方式对Redis, Memcached数据库进行管理.维护. 功能包括:状态参数监控,NoSQL数据库 ...
- Java代码启动/关闭进程
ProcessBuilder builder = new ProcessBuilder(命令,参数,参数...); Process process = builder.start(); br = ne ...
- dashboard服务
1.上传镜像,并导入,打标签 2.创建dashboard的deployment和service apiVersion: extensions/v1beta1 kind: Deployment meta ...
- JDK9新特性实战:简化流关闭新姿势。
做Java开发的都知道,每个资源的打开都需要对应的关闭操作,不然就会使资源一直占用而造成资源浪费,从而降低系统性能. 关于资源的关闭操作,从JDK7-JDK9有了不少的提升及简化. JDK6 在JDK ...
- 基础数据类型汇总补充,python集合与深浅拷贝
一.基础数据类型汇总补充 1.查看str所有方法方式 2.列表:在循环中删除元素,易出错或报错(飘红) lis = [11,22,33,44,55] # for i in range(len(lis) ...