[POI2005]AUT-The Bus
树状数组维护前缀最大值+扫描线DP
#include"cstdio"
#include"cstring"
#include"iostream"
#include"algorithm"
using namespace std;
const int MAXN=1e5+5;
int n,m,c,maxn;
long long Tib[MAXN];
struct rpg{
int x,y,v;
int rey;
}a[MAXN];
bool cmp1(rpg a,rpg b){return a.y<b.y;}
bool cmp2(rpg a,rpg b){return a.x==b.x?a.y<b.y:a.x<b.x;}
long long cask(int x)
{
long long ans=0;
for(int i=x;i;i&=i-1) ans=max(ans,Tib[i]);
return ans;
}
void ins(int x,long long v)
{
for(int i=x;i<=maxn;i+=i&-i) Tib[i]=max(Tib[i],v);
return;
}
int main()
{
scanf("%d%d%d",&n,&m,&c);
for(int i=1;i<=c;++i) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].v);
sort(a+1,a+c+1,cmp1);a[1].rey=1;
for(int i=2;i<=c;++i) a[i].rey=a[i].y==a[i-1].y?a[i-1].rey:a[i-1].rey+1;
maxn=a[c].rey;
sort(a+1,a+c+1,cmp2);
for(int i=1;i<=c;++i){
long long tmp=cask(a[i].rey)+a[i].v;
ins(a[i].rey,tmp);
}printf("%lld\n",cask(maxn));
return 0;
}
[POI2005]AUT-The Bus的更多相关文章
- 「BZOJ1537」Aut – The Bus(变形Dp+线段树/树状数组 最优值维护)
网格图给予我的第一反应就是一个状态 f[i][j] 表示走到第 (i,j) 这个位置的最大价值. 由于只能往下或往右走转移就变得显然了: f[i][j]=max{f[i-1][j], f[i][j-1 ...
- bzoj 1537: [POI2005]Aut- The Bus 线段树
bzoj 1537: [POI2005]Aut- The Bus 先把坐标离散化 设f[i][j]表示从(1,1)走到(i,j)的最优解 这样直接dp::: f[i][j] = max{f[i-1][ ...
- BZOJ1537: [POI2005]Aut- The Bus
1537: [POI2005]Aut- The Bus Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 158 Solved: 100[Submit][S ...
- BZOJ 1537: [POI2005]Aut- The Bus(dp + BIT)
对y坐标离散化, 然后按x坐标排序, dp. 一个点(x, y), 设到达这个点接到的最多乘客数为t, 那么t可以用来更新y'>=y的所有点.用树状数组维护最大值. -------------- ...
- 树状数组 二维偏序【洛谷P3431】 [POI2005]AUT-The Bus
P3431 [POI2005]AUT-The Bus Byte City 的街道形成了一个标准的棋盘网络 – 他们要么是北南走向要么就是西东走向. 北南走向的路口从 1 到 n编号, 西东走向的路从1 ...
- 洛谷P3431 [POI2005]AUT-The Bus
P3431 [POI2005]AUT-The Bus 题目描述 The streets of Byte City form a regular, chessboardlike network - th ...
- Bzoj 1537: [POI2005]Aut- The Bus 题解 [由暴力到正解]
1537: [POI2005]Aut- The Bus Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 387 Solved: 264[Submit][S ...
- 洛谷 P3431:[POI2005]AUT-The Bus(离散化+DP+树状数组)
题目描述 The streets of Byte City form a regular, chessboardlike network - they are either north-south o ...
- bzoj 1537 [POI2005]Aut- The Bus(DP+BIT)
[题意] 顺序经过k个点,求获得的最大权值和. [思路] 设f[i]表示到第i个点,则有转移式: f[i]=min{ f[j]+w[i] } x[j]<=x[i],y[j]<=y[i] 满 ...
- 【刷题】BZOJ 1537 [POI2005]Aut- The Bus
Description Byte City 的街道形成了一个标准的棋盘网络 – 他们要么是北南走向要么就是西东走向. 北南走向的路口从 1 到 n编号, 西东走向的路从1 到 m编号. 每个路口用两个 ...
随机推荐
- Developer Friendly | 基础设施即代码的事实标准Terraform已支持京东云!
Developer Friendly | 基础设施即代码的事实标准Terraform已支持京东云! Chef.Puppet.Ansible.SaltStack 都可以称为配置管理工具,这些工具的主要目 ...
- driver failed programming external connectivity on endpoint wordpress
docker run 镜像的时候报错: [root@docker ~]# docker run -itd --name wordpress -p 88:80 wordpress:v1b77482f80 ...
- remote link Centos6.6 Horrible Slow
客户端win7 , 本地直连,secureCRT连接Centos6.6 速度巨慢,FTP tool almost cannot link in. 即使用cmd ftp 也是反应30s以上.
- springcloud(十)-Zuul微服务网关
为什么要使用微服务网关 前面的文章我们介绍了,Eureka用于服务的注册于发现,Feign支持服务的调用以及均衡负载,Hystrix处理服务的熔断防止故障扩散,Spring Cloud Config服 ...
- 云服务器、vps、虚拟主机的区别
云服务器 Elastic Compute Service, 简称ECS 好多人理解云服务器和VPS一样,更有甚者说以前的VPS现在的说法就是云服务器,其实不然,云服务器是一个计算,网络,存储的组合.简 ...
- service iptables xxx无效命令的情况下,如何启动/重启iptables
最近在CentOS 7.6下使用service iptables xxx相关命令,提示如下错误:The service command supports only basic LSB actions ...
- Compile git version inside go binary
Compile git version inside go binary Abstract 在我们编写的程序中总是希望可以直接查阅程序的版本,通过--version参数就会输出如下版本信息. Buil ...
- vue下拉搜索
vue版本是1.0.21 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- webpack使用 babili-webpack-plugin 报错 "original.line and original.column are not numbers"
按照这个解决 https://github.com/chentsulin/electron-react-boilerplate/issues/1300 changing "babili-we ...
- 2-4 js基础-事件对象小结
var e=ev||event; e.cancelBubble=true; document.documentElement html document.body ...