树状数组维护前缀最大值+扫描线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. AssertJ断言系列<一>

    1 - Get AssertJ Core assertions Maven的pom.xml加入如下配置: <dependency> <groupId>org.assertj&l ...

  2. 【1】JMicro微服务-RPC体验

    如非授权,禁止用于商业用途,转载请注明出处作者:mynewworldyyl JMICRO运行简单服务提供者和消费者 1. 下载源代码 git checkout https://github.com/m ...

  3. leetcode-479-Largest Palindrome Product(找到两个乘数相乘得到的最大的回文数)

    题目描述: Find the largest palindrome made from the product of two n-digit numbers. Since the result cou ...

  4. 2017 最新的 cocoaPods 安装方法

    经过努力终于发现了最新的 解决cocoaPods安装的办法: taobao Gems 源已停止维护,现由 ruby-china 提供镜像服务 第一步:安装rvm, 不管需不需要升级ruby,rvm可以 ...

  5. jenkins发送测试报告邮件

     1.安装插件 Email Extension Plugin 2.设置Extended E-mail Notification a."系统管理"--“系统设置”.配置Extende ...

  6. Hexo博客系列(二)-在多台机器上利用Hexo发布博客

    [原文链接]:https://www.tecchen.xyz/blog-hexo-env-02.html 我的个人博客:https://www.tecchen.xyz,博文同步发布到博客园. 由于精力 ...

  7. stark - 4 ⇲ 视图函数

    ✘  list_view 处理表格(默认是显示表结构的所有字段) 1 list_display = self.get_list_display() # 4.1处理表头 header_list = [] ...

  8. poj3207 Ikki's Story IV - Panda's Trick 2-SAT

    题目传送门 题意:在一个圆上顺时针安放着n个点,给出m条线段连接端点,要求线段不相交,线段可以在圆内也可以在圆外,问是否可以. 思路:假设一条线段,放在圆外是A,放在园内是A',那么两条线段如果必须一 ...

  9. Mac下常用按键符号⌘(command)、⌥(option)、⇧(shift)、⇪(caps lock)、⌃(control)、↩(return)、⌅(enter)

    常用符号如下: ⌘(command) ⌥(option) ⇧(shift) ⇪(caps lock) ⌃(control) ↩(return) ⌅(enter) 对应键盘的位置如下: 如果每次都不记得 ...

  10. 何为Web App,何为Hybird App

    这些概念听起来很火,当下也很流行,真正理解起来却并非易事.如果让我来全面的解释Web App和Hybird App,我觉得还有些困难. 这篇文章只是我深入了解移动领域开发过程中的不断整理和总结,其中涉 ...