一眼看过去就x排序扫描一下,y是1e9的离散化一下,每层用树状数组维护一下,然后像dp倒着循环似的树状数组就用y倒着插就可行了。

类似题目练习:BZOJ4653BZOJ1218

  1. #pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <ctime>
  7. #include <cctype>
  8. #include <climits>
  9. #include <iostream>
  10. #include <iomanip>
  11. #include <algorithm>
  12. #include <string>
  13. #include <sstream>
  14. #include <stack>
  15. #include <queue>
  16. #include <set>
  17. #include <map>
  18. #include <vector>
  19. #include <list>
  20. #include <fstream>
  21. #include <bitset>
  22. #define init(a, b) memset(a, b, sizeof(a))
  23. #define rep(i, a, b) for (int i = a; i <= b; i++)
  24. #define irep(i, a, b) for (int i = a; i >= b; i--)
  25. using namespace std;
  26.  
  27. typedef double db;
  28. typedef long long ll;
  29. typedef unsigned long long ull;
  30. typedef pair<int, int> P;
  31. const int inf = 0x3f3f3f3f;
  32. const ll INF = 1e18;
  33.  
  34. template <typename T> void read(T &x) {
  35. x = ;
  36. int s = , c = getchar();
  37. for (; !isdigit(c); c = getchar())
  38. if (c == '-') s = -;
  39. for (; isdigit(c); c = getchar())
  40. x = x * + c - ;
  41. x *= s;
  42. }
  43.  
  44. template <typename T> void write(T x) {
  45. if (x < ) x = -x, putchar('-');
  46. if (x > ) write(x / );
  47. putchar(x % + '');
  48. }
  49.  
  50. template <typename T> void writeln(T x) {
  51. write(x);
  52. puts("");
  53. }
  54.  
  55. const int maxn = 1e5 + ;
  56. int T, n;
  57. struct cord {
  58. int x, y, v;
  59.  
  60. bool operator < (const cord& rhs) const {
  61. if (x != rhs.x) return x < rhs.x;
  62. return y > rhs.y;
  63. }
  64. }a[maxn];
  65. int yy[maxn], tot;
  66. struct BIT {
  67. int F[maxn];
  68.  
  69. void Update(int pos, int val) {
  70. for (; pos <= tot; pos += pos&-pos)
  71. F[pos] = max(F[pos], val);
  72. }
  73.  
  74. int Query(int pos) {
  75. int ret = ;
  76. for (; pos; pos -= pos&-pos)
  77. ret = max(ret, F[pos]);
  78. return ret;
  79. }
  80. }bit;
  81.  
  82. int main() {
  83. for (read(T); T; T--, tot = ) {
  84. read(n);
  85. rep(i, , n) {
  86. read(a[i].x);
  87. read(a[i].y);
  88. read(a[i].v);
  89. yy[++tot] = a[i].y;
  90. }
  91. sort(yy + , yy + + tot);
  92. tot = unique(yy + , yy + + tot) - yy - ;
  93. rep(i, , n) {
  94. a[i].y = lower_bound(yy + , yy + + tot, a[i].y) - yy;
  95. }
  96.  
  97. sort(a + , a + + n);
  98. init(bit.F, );
  99. rep(i, , n) {
  100. bit.Update(a[i].y, bit.Query(a[i].y - ) + a[i].v);
  101. }
  102. writeln(bit.Query(tot));
  103. }
  104. return ;
  105. }

HDU6447(离散化扫描线+树状数组)的更多相关文章

  1. HDU 5862 Counting Intersections (离散化+扫描线+树状数组)

    题意:给你若干个平行于坐标轴的,长度大于0的线段,且任意两个线段没有公共点,不会重合覆盖.问有多少个交点. 析:题意很明确,可是并不好做,可以先把平行与x轴和y轴的分开,然后把平行y轴的按y坐标从小到 ...

  2. 【BZOJ1818】[Cqoi2010]内部白点 扫描线+树状数组

    [BZOJ1818][Cqoi2010]内部白点 Description 无限大正方形网格里有n个黑色的顶点,所有其他顶点都是白色的(网格的顶点即坐标为整数的点,又称整点).每秒钟,所有内部白点同时变 ...

  3. HDU 5862 Counting Intersections 扫描线+树状数组

    题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5862 Counting Intersections Time Limit: 12000/ ...

  4. [BZOJ4822][CQOI2017]老C的任务(扫描线+树状数组)

    4822: [Cqoi2017]老C的任务 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 379  Solved: 203[Submit][Statu ...

  5. FZU 2225 小茗的魔法阵 扫描线+树状数组

    这个题和一个CF上的找"Z"的题差不多,都是扫描线+树状数组 从右上角的主对角线开始扫描,一直扫到左下角,每次更新,右延伸等于该扫描线的点,注意在其所在的树状数组更新就好了 时间复 ...

  6. 【loj6041】「雅礼集训 2017 Day7」事情的相似度 后缀自动机+STL-set+启发式合并+离线+扫描线+树状数组

    题目描述 给你一个长度为 $n$ 的01串,$m$ 次询问,每次询问给出 $l$ .$r$ ,求从 $[l,r]$ 中选出两个不同的前缀的最长公共后缀长度的最大值. $n,m\le 10^5$ 题解 ...

  7. 【bzoj4540】[Hnoi2016]序列 单调栈+离线+扫描线+树状数组区间修改区间查询

    题目描述 给出一个序列,多次询问一个区间的所有子区间最小值之和. 输入 输入文件的第一行包含两个整数n和q,分别代表序列长度和询问数.接下来一行,包含n个整数,以空格隔开,第i个整数为ai,即序列第i ...

  8. 【BZOJ3488】[ONTAK2010]Highways 扫描线+树状数组

    [BZOJ3488][ONTAK2010]Highways Description 给一棵n个点的树以及m条额外的双向边q次询问,统计满足以下条件的u到v的路径:恰经过一条额外的边不经过树上u到v的路 ...

  9. 【BZOJ4009】[HNOI2015]接水果 DFS序+整体二分+扫描线+树状数组

    [BZOJ4009][HNOI2015]接水果 Description 风见幽香非常喜欢玩一个叫做 osu!的游戏,其中她最喜欢玩的模式就是接水果.由于她已经DT FC 了The big black, ...

随机推荐

  1. SGU 194 Reactor Cooling 无源汇带上下界可行流

    Reactor Cooling time limit per test: 0.5 sec. memory limit per test: 65536 KB input: standard output ...

  2. effctive C++ 读书笔记 条款 16

    条款16 成对使用new和delete时要採取同样形式 #include <iostream> #include <string> using namespace std; / ...

  3. configuration类详解

    hadoop中,组件配置是由Hadoop的Configuration的一个实例实现.(在源码包的org.apache.hadoop.conf中可以找到)先上个类图:这只是部分的,Configuraat ...

  4. MFC中CAsyncSocket和CSocket

    原文链接:https://blog.csdn.net/libaineu2004/article/details/40395917 摘要部分重点: 1.CAsyncSocket类逐个封装了WinSock ...

  5. boogo08---中间件

    package main //中间件1:只允许特定host请求过来 import ( "fmt" "net/http" ) //SingleHost是一个中间件 ...

  6. java包和javax包的区别

    基本类库和扩展类库 一般的lang,util都放在java.包 servlet放在javax包 以前sun把java中的叫核心库,把javax中的叫扩展库.现在sun已经把java和javax中的都叫 ...

  7. POJ3680 Intervals —— 区间k覆盖问题(最小费用流)

    题目链接:https://vjudge.net/problem/POJ-3680 Intervals Time Limit: 5000MS   Memory Limit: 65536K Total S ...

  8. Pycharm中如何安装python库

    1首先打开pycharm工具,选择File中的Setting选项,如下图所示 2在打开的setting界面中我们点击python的解释器,你会看到很多导入的第三方库,如下图所示,点击最右边的加号 3在 ...

  9. [Selenium] Automation Test Manual(Selenium)

    http://www.cnblogs.com/puresoul/p/3483055.html http://www.360doc.com/content/14/0913/10/13497042_409 ...

  10. maven(二)创建一个maven的web项目中解决Cannot change version of project facet Dynamic web module to 2.5

    我们用Eclipse创建Maven结构的web项目的时候选择了Artifact Id为maven-artchetype-webapp,由于这个catalog比较老,用的servlet还是2.3的,而一 ...