SGU 199 Beautiful People
来源:互联网 发布:linux 打开防火墙端口 编辑:程序博客网 时间:2024/06/10 13:24
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define N 500010int pre[N],id[N];struct peo{int s,b,id;void read(){scanf("%d%d",&s,&b);}bool operator <(const peo &t)const{if(s==t.s) return b>t.b;else return s<t.s;}}mem[N];int main(){int n,m,i,j,k;while(scanf("%d",&n)!=EOF){for(i=1;i<=n;i++){mem[i].read();mem[i].id=i;}sort(mem+1,mem+1+n);int len=1,low,high;id[1]=1;for(i=2;i<=n;i++){if(mem[id[len]].b<mem[i].b){len++;id[len]=i;pre[i]=id[len-1];}low=1,high=len;while(low<high){int mid=(low+high)/2;if(mem[id[mid]].b<mem[i].b) low=mid+1;else high=mid;}id[low]=i;pre[i]=id[low-1];}printf("%d\n",len);for(i=id[len];i;i=pre[i]){printf("%d ",mem[i].id);}printf("\n");}return 0;}
0 0
- sgu 199 Beautiful People
- SGU--199 beautiful people
- SGU 199 Beautiful People
- sgu 199 Beautiful People dp
- SGU 119 Beautiful People
- ZOJ Problem Set - 2319 Beautiful People || sgu 199
- SGU 199 Beautiful People lis O(nlogn)算法
- SGU 199. Beautiful People 二维LIS
- sgu 199 Beautiful People (DP-LIS O(nlogn)算法 输出所选元素)
- sgu 199 beautiful people(nlog 的LIS并输出路径)
- Beautiful People
- SGU 199. Beautiful People(最长上升子序列nlogn LIS)
- zoj 3519 Beautiful People
- ZOJ 2319 Beautiful People
- ZOJ 2319 Beautiful People
- zoj 2319 Beautiful People
- ACdream 1216 Beautiful People
- Beautiful People (zoj 2319)
- [LeetCode] Distinct Subsequences
- 原码,反码和补码
- poj 1159 Palindrome
- Android中SoundPool和MediaPlayer的区别
- 鸟哥的linux服务器架设篇学习笔记——CentOS相关网络设定
- SGU 199 Beautiful People
- Elasticsearch搜索类型(query type)详解
- Gas Station
- 初学Android,音频管理器之控制音频(六十六)
- 黑马程序员——Java泛型知识点
- CF 题目集锦 PART 1 #138 div 1 A
- BZOJ 3295 动态逆序对 CDQ分治
- LightOj 1110 An Easy LCS
- Unity中PlayerPrefs.DeleteAll()无法清除数据的问题