#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100000+3;
int x[N], y[N], Y[N], A[N], nums[N];
int C[N];
int cmp(int i,int j){
if(x[i]==x[j])return y[i]<y[j];
return x[i]<x[j];
}
int lowbit(int t){return t&(-t);}
void update(int t,int delta)
{
while(t<N) C[t]=max(C[t],delta), t+=lowbit(t);
}
int query(int t){
int tmp=-1;
while(t>0)tmp=max(tmp,C[t]), t-=lowbit(t);
return tmp;
}
int main()
{
//freopen("in.txt","r",stdin);
int n,m,k,ans=0;
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=k;++i)scanf("%d%d%d",&y[i],&x[i],&nums[i]), Y[i]=y[i];
for(int i=1;i<=k;++i)A[i]=i;
sort(A+1,A+1+k,cmp);
sort(Y+1,Y+1+k);
for(int i=1;i<=k;++i)
{
int cur=A[i];
y[cur]=lower_bound(Y+1,Y+1+k, y[cur])-Y;
int h=query(y[cur])+nums[cur];
ans=max(ans,h);
update(y[cur], h);
}
printf("%d",ans);
return 0;
}

[POI2005]AUT-The Bus 树状数组维护最大前缀和的更多相关文章

  1. [poj3378] Crazy Thairs (DP + 树状数组维护 + 高精度)

    树状数组维护DP + 高精度 Description These days, Sempr is crazed on one problem named Crazy Thair. Given N (1 ...

  2. HDU 5869 Different GCD Subarray Query (GCD种类预处理+树状数组维护)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5869 问你l~r之间的连续序列的gcd种类. 首先固定右端点,预处理gcd不同尽量靠右的位置(此时gc ...

  3. POJ 3321 Apple Tree(后根遍历将树转化成序列,用树状数组维护)

    题意:一棵树,有很多分叉,每个分叉上最多有1个苹果. 给出n,接下来n-1行,每行u,v,表示分叉u,v之间有树枝相连.这里数据中u相当于树中的父节点,v相当于子节点. 给出两个操作: 1.C x  ...

  4. 第十二届湖南省赛G - Parenthesis (树状数组维护)

    Bobo has a balanced parenthesis sequence P=p 1 p 2…p n of length n and q questions. The i-th questio ...

  5. LOJ107. 维护全序集【树状数组维护全序集】

    题目描述 这是一道模板题,其数据比「普通平衡树」更强. 如未特别说明,以下所有数据均为整数. 维护一个多重集 S ,初始为空,有以下几种操作: 把 x 加入 S 删除 S 中的一个 x,保证删除的 x ...

  6. 【BZOJ2124】等差子序列 树状数组维护hash值

    [BZOJ2124]等差子序列 Description 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…<pLen<=N ...

  7. ACM-ICPC 2018 徐州赛区网络预赛 G. Trace【树状数组维护区间最大值】

    任意门:https://nanti.jisuanke.com/t/31459 There's a beach in the first quadrant. And from time to time, ...

  8. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains 【树状数组维护区间最大值】

    题目传送门:http://codeforces.com/contest/799/problem/C C. Fountains time limit per test 2 seconds memory ...

  9. 2018中国大学生程序设计竞赛 - 网络选拔赛 1010 YJJ's Salesman 【离散化+树状数组维护区间最大值】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/O ...

随机推荐

  1. hdu 4858 容器的简单模拟

    我用临接表模拟容器超时 #include<stdio.h> #include<string.h> #include<vector> using namespace ...

  2. eclipse jvm调优

    1.初始参数 -Xms256m-Xmx1024m 2.在eclipse.ini中加入,注意一点的是D:/soft/eclipse-jee,这个目录必须存在,启动时并不会自动目录 -verbose:gc ...

  3. 0923如何利用mysqlbinlog日志闪回

    转自 https://github.com/danfengcao/binlog2sql,感谢作者的提供 binlog2sql 从MySQL binlog解析出你要的SQL.根据不同选项,你可以得到原始 ...

  4. ZOJ 1450

    最小圆覆盖 #include <iostream> #include <algorithm> #include <cstdio> #include <cmat ...

  5. 【cl】cmd相关命令

    cd  进入目录 dir  列出当前目录下的文件[在linux上是ls] e:  进入E盘 tab键可以快速进入目录

  6. MySQL Study之--MySQL体系结构深入解析

    MySQL Study之--MySQL体系结构深入解析 MySQL体系架构 由连接池组件.管理服务和⼯工具组件.sql接口组件.查询分析器组件.优化器组件.缓冲组件.插件式存储引擎.物理⽂文件组成.m ...

  7. python基于selenium+cv2+numpy实现登录某大型电商系统

    首先贴上我的安装包 一.selenium安装 I.打开pycharm,点击Settings,找到Project Interpreter,点击右边的下拉菜单下的show All...选项 II.点击sh ...

  8. 一个简单的演示用的Linux字符设备驱动程序

    实现如下的功能:--字符设备驱动程序的结构及驱动程序需要实现的系统调用--可以使用cat命令或者自编的readtest命令读出"设备"里的内容--以8139网卡为例,演示了I/O端 ...

  9. [SPOJ 30669] Ada and Trip

    [题目链接] https://www.spoj.com/problems/ADATRIP/ [算法] 直接使用dijkstra堆优化算法即可 [代码] #include<bits/stdc++. ...

  10. ClassLoader.getResourceAsStream(name);获取配置文件的方法

    ClassLoader.getResourceAsStream(name);路径问题 InputStream in = getClass().getResourceAsStream('/'+" ...