树状数组维护前缀最大值+扫描线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的更多相关文章

  1. 「BZOJ1537」Aut – The Bus(变形Dp+线段树/树状数组 最优值维护)

    网格图给予我的第一反应就是一个状态 f[i][j] 表示走到第 (i,j) 这个位置的最大价值. 由于只能往下或往右走转移就变得显然了: f[i][j]=max{f[i-1][j], f[i][j-1 ...

  2. 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][ ...

  3. BZOJ1537: [POI2005]Aut- The Bus

    1537: [POI2005]Aut- The Bus Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 158  Solved: 100[Submit][S ...

  4. BZOJ 1537: [POI2005]Aut- The Bus(dp + BIT)

    对y坐标离散化, 然后按x坐标排序, dp. 一个点(x, y), 设到达这个点接到的最多乘客数为t, 那么t可以用来更新y'>=y的所有点.用树状数组维护最大值. -------------- ...

  5. 树状数组 二维偏序【洛谷P3431】 [POI2005]AUT-The Bus

    P3431 [POI2005]AUT-The Bus Byte City 的街道形成了一个标准的棋盘网络 – 他们要么是北南走向要么就是西东走向. 北南走向的路口从 1 到 n编号, 西东走向的路从1 ...

  6. 洛谷P3431 [POI2005]AUT-The Bus

    P3431 [POI2005]AUT-The Bus 题目描述 The streets of Byte City form a regular, chessboardlike network - th ...

  7. Bzoj 1537: [POI2005]Aut- The Bus 题解 [由暴力到正解]

    1537: [POI2005]Aut- The Bus Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 387  Solved: 264[Submit][S ...

  8. 洛谷 P3431:[POI2005]AUT-The Bus(离散化+DP+树状数组)

    题目描述 The streets of Byte City form a regular, chessboardlike network - they are either north-south o ...

  9. 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] 满 ...

  10. 【刷题】BZOJ 1537 [POI2005]Aut- The Bus

    Description Byte City 的街道形成了一个标准的棋盘网络 – 他们要么是北南走向要么就是西东走向. 北南走向的路口从 1 到 n编号, 西东走向的路从1 到 m编号. 每个路口用两个 ...

随机推荐

  1. clang命令理解程序

    Xcode 创建一个mac OS   command Line Tool程序 步骤打开终端  cd + 工程路径(绝对路径)(注:拖拽main.m文件到终端) input —preprocessor— ...

  2. 在IDEA中 SFTP 进行发布操作

    1, 2, 3, 4, 成功了 补充:] 也可以使用手动写配置文件的方式来的

  3. L06-Ubuntu系统中部署Vagrant和VirtualBox

    一.前言 1.Vagrant是一个搭建完整的虚拟开发环境的工具~~~更多关于Vagrant理论可查看这篇博文https://www.cnblogs.com/davenkin/p/vagrant-vir ...

  4. jquery scrollTop()与scrollLeft()

    1.scrollLeft() scrollLeft() 方法设置或返回被选元素的水平滚动条位置. 提示:当滚动条位于最左侧时,位置是 0. 当用于返回位置时:该方法返回第一个匹配元素的滚动条的水平位置 ...

  5. You need to use a Theme.AppCompat theme (or descendant) with this activity问题

    You need to use a Theme.AppCompat theme (or descendant) with this activity问题 https://blog.csdn.net/j ...

  6. appium获取toast方法

    配置toast请注意: 1.指定desired_caps["automationName"] = "UiAutomator2" 2.要求安装jdk1.8 64位 ...

  7. FJWC2019 最短路

    题目描述 有一张无向图,开始的时候所有边权为1,所有点没有权值,现在给定一个整数k,表示可以将k个点的点权设置为1,求点0到n-1的最短路最长是多少 Solution 网络流好题[然而本蒟蒻还是不会] ...

  8. PowerDesigner16 生成的备注脚本,在sql server 2008 中报“对象名 'sysproperties' 无效”的错误的解决办法

    主要是在建模时我们对表.列增加了些说明注释,而Sql2005之后系统表sysproperties已废弃删除而改用sys.extended_properties所致. 1.修改Table TableCo ...

  9. 浏览器缓存如何控制? && 在url框中回车、F5 和 Ctrl + F5的区别是什么?

    第一部分: 浏览器缓存如何控制?   最近在做网站,但是不知道缓存是什么东西怎么能行! 如何实现HTTP缓存呢? 下面我们来一步一步的探寻实现机制把. 方案一: 无缓存   说明: 浏览器向服务器请求 ...

  10. Executors多线程

    介绍new Thread的弊端及Java四种线程池的使用,对Android同样适用.本文是基础篇,后面会分享下线程池一些高级功能. 1.new Thread的弊端执行一个异步任务你还只是如下new T ...