博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj2319Beautiful People Dp
阅读量:4621 次
发布时间:2019-06-09

本文共 958 字,大约阅读时间需要 3 分钟。

最长上升子序列的nlogn的解法,不过要注意的是 x按从小到大排序,y要按从大到小排序。对于同样的x,在维护的单调数组中y应该保留较小的那个。

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;const int maxn = 111111;typedef long long LL;struct Node{ int x; int y; int id;}node1[maxn],node[maxn];int erfen(int a[], int l, int r, int key){ int ans = -1; while (l <= r){ int mid = (l + r) >> 1; if (a[mid] > key) { ans = mid; } if (a[mid] > key) r = mid - 1; else l = mid + 1; } return ans;}int cmp(const Node &a,const Node &b){ if(a.x==b.x) return a.y>b.y; return a.x
> T; while (T--){ cin >> n; for (int i = 1; i <= n; i++){ scanf("%d%d", &node[i].x, &node[i].y); node[i].id = i; node1[i] = node[i]; } sort(node + 1, node + 1 + n, cmp); cnt = 1; ans[cnt] = node[1].y; vis[cnt++] = node[1].id; father[node[1].id] = node[1].id; //cout<

 

转载于:https://www.cnblogs.com/yigexigua/p/4125079.html

你可能感兴趣的文章
when case group by 的用法集合
查看>>
洛谷P1908 逆序对
查看>>
转义符
查看>>
poj 1019
查看>>
asp.net mvc上传文件
查看>>
bitmq集群高可用测试
查看>>
主成分分析(PCA)原理详解
查看>>
短信验证接口网址
查看>>
Geohash距离估算
查看>>
Demon_背包系统(实现装备栏,背包栏,可以切换装备)
查看>>
记录:一次数据库被恶意修改配置文件的问题
查看>>
redis 持久化
查看>>
解决Jupyter notebook[import tensorflow as tf]报错
查看>>
Windows平台下使用ffmpeg和segmenter实现m3u8直播点播
查看>>
python网络画图——networkX
查看>>
ubuntu16.04文件形式安装mongodb
查看>>
SpringBoot------ActiveMQ安装
查看>>
详细了解 int? 类型
查看>>
字符串匹配 ?kmp : hash
查看>>
mongod.service: control process exited, code=exited status=1
查看>>