#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. Ubuntu镜像文件下载

    Ubuntu镜像文件下载 http://www.traffictool.net/vmware/ubuntu1404t.html 下载之后可以使用vmplayer启动: user/password ro ...

  2. [Python] Use Static Typing in Python 3.6

    In this lesson, you will learn how to statically type variables in Python 3.6 Static typing can help ...

  3. redis(四))——多实例化——实现主从配置

    引言 redis是一个key-value存储系统. 和Memcached类似,它支持存储的value类型相对很多其它,包含string(字符串).list(链表).set(集合)和zset(有序集合) ...

  4. selenium实例学习地址

    一个完整的maven配置selenium webdriver工程实例   http://www.spasvo.com/ceshi/open/kygncsgj/Selenium/201312209580 ...

  5. Kinect for Windows SDK v2.0 开发笔记 (十五) 手势帧

     (转载请注明出处) 使用SDK: Kinect for Windows SDK v2.0 public preview1409 同前面,由于SDK未完毕,不附上函数/方法/接口的超链接. 这次最 ...

  6. luogu2754 星际转移问题 网络流

    题目大意:地球与月球间有可容纳无限人的太空站,还有在太空站与星球间按周期行驶的.有固定容量的太空船,每一艘太空船从一个太空站驶往任一太空站耗时均为 1.地球上有一定数量的人,问所有人到月球最少需要多少 ...

  7. 【NOIP 2011】 Mayan游戏

    [题目链接] https://www.luogu.org/problemnew/show/P1312 [算法] 深度优先搜索 [代码] #include<bits/stdc++.h> us ...

  8. 杂项:Kafka

    ylbtech-杂项:Kafka Kafka是由Apache软件基金会开发的一个开源流处理平台,由Scala和Java编写.Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站 ...

  9. [Plugin] WEB版一次选择多个文件进行批量上传(swfupload)的解决方案

    URL:http://www.cnblogs.com/chillsrc/archive/2010/02/21/1670594.html 说明:功能完全支持ie和firefox浏览器! 一般的WEB方式 ...

  10. ORACLE 11g 生产中高水位线(HWM)处理

    数据库中表不断的insert,delete,update,导致表和索引出现碎片.这会导致HWM之前有很多的空闲空间,而oracle在做全表扫描的时候会读取HWM一下的所有块,这样会产生更多的IO,影响 ...