#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. POJ 4046 Sightseeing

    Sightseeing Time Limit: 5000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID ...

  2. 洛谷 P1649 [USACO07OCT]障碍路线Obstacle Course

    P1649 [USACO07OCT]障碍路线Obstacle Course 题目描述 Consider an N x N (1 <= N <= 100) square field comp ...

  3. 解决Chrome在隐身模式下无法播放Flash视频

    在地址栏输入: chrome://flags/#prefer-html-over-flash 打开如下界面,并设置成如下所示: 然后点击左下方重启按钮: 参考: http://www.cnblogs. ...

  4. android中常见的内存泄漏和解决的方法

    android中的内存溢出预计大多数人在写代码的时候都出现过,事实上突然认为工作一年和工作三年的差别是什么呢.事实上干的工作或许都一样,产品汪看到的结果也都一样,那差别就是速度和质量了. 写在前面的一 ...

  5. C语言播放声音最简单的两种方法

    1. 假设仅须要播放波形文件wav格式的声音,非常easy.仅仅需一句话: PlaySound(TEXT("Data\\1.wav"), NULL, SND_FILENAME | ...

  6. Task.ConfigureAwait

    public ConfiguredTaskAwaitable ConfigureAwait( bool continueOnCapturedContext ) Configures an awaite ...

  7. Node.js:JXcore

    ylbtech-Node.js:JXcore 1.返回顶部 1. Node.js JXcore 打包 Node.js 是一个开放源代码.跨平台的.用于服务器端和网络应用的运行环境. JXcore 是一 ...

  8. 【React Natvie】React-native-swiper的安装和配置【ES6】

    react-native-swiper轮播图,是我们开发中特别常见的效果,首先感谢编写react-native-swiper的大神,让我们方便了很多.这个框架主要是用来做轮播图,焦点图等,内置了各种样 ...

  9. MYSQL5.6和5.7编译标准化安装与配置

    文档结构图如下: 一.前期规划 1.软件环境以及说明 操作系统:RedHat Linux 6.7 64位 数 据 库:MYSQL5.6.38/5.7.20 MySQL 5.6:初始化数据时需要进到家目 ...

  10. B - Mike and Cellphone(map)

    Problem description While swimming at the beach, Mike has accidentally dropped his cellphone into th ...