hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升序列nlogn
来源:互联网 发布:老年保健数据 编辑:程序博客网 时间:2024/05/29 19:24
#include<bits/stdc++.h>using namespace std;int d[500000+5],a[500000+5];int Binary_search(int s,int t,int i){ int mid; while(s<t) { mid=(s+t)>>1; if(i>=d[mid]) s=mid+1; else t=mid; } return s;}int main(){ int i,n,b,p,r,k,cas=0; while(~scanf("%d",&n)) { for(i=0; i<n; i++) { scanf("%d%d",&p,&r); a[p]=r; } b=1; memset(d,0,sizeof(d)); d[0]=a[1]; for(i=2; i<=n; i++) { k=Binary_search(0,b-1,a[i]); if(d[k]>=a[i]) d[k]=a[i]; else d[b++]=a[i]; } printf("Case %d:\n",++cas); if(b==1) printf("My king, at most 1 road can be built.\n\n"); else printf("My king, at most %d roads can be built.\n\n",b); } return 0;}
0 0
- hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升子序列(nlogn)
- HDU-1025 Constructing Roads In JGShining's Kingdom O(nlogn)的最长上升子序列
- 最长上升子序列 nlogn算法 hdu 1025 Constructing Roads In JGShining's Kingdom
- hdu 1025 Constructing Roads In JGShining's Kingdom(最长上升子序列nlogn算法)
- hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升序列nlogn
- HDU 1025-Constructing Roads In JGShining's Kingdom(最长上升子序列 NlogN复杂度)
- hdu 1025 Constructing Roads In JGShining's Kingdom(最长上升子序列(LIS)O(nlogn)算法)
- Hdu 1025 Constructing Roads In JGShining's Kingdom 最大上升子序列nlogn算法
- HDU 1025(Constructing Roads In JGShining's Kingdom)最长不降子序列nlogn
- HDU 1025 Constructing Roads In JGShining's Kingdom 最长子序列的nlogn算法
- hdu 1025 Constructing Roads In JGShining's Kingdom【即求最长上升子序列】
- HDU 1025 Constructing Roads In JGShining's Kingdom(最长上升子序列+n*logn算法)
- hdu 1025 Constructing Roads In JGShining's Kingdom(树状数组求最长上升子序列)
- hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升序列
- hdu 1025 Constructing Roads In JGShining's Kingdom (最长上升子序列)
- hdu 1025 Constructing Roads In JGShining's Kingdom(最长上升序列n*logn算法)
- hdu 1025 Constructing Roads In JGShining's Kingdom(二分法+最长上升子序列)
- 【DP】HDU 1025 Constructing Roads In JGShining's Kingdom 最长上升子序列
- 分布式事务
- 生成活动码,每次获取的记录不重复
- JavaScript prototype实例
- CentOS修改系统时间
- 2015、9、10 已忘初心
- hdu 1025 Constructing Roads In JGShining's Kingdom 最长上升序列nlogn
- HashSet
- linux kill 关闭进程命令
- 程序员如何持续提升自己的开发技能
- 单链表
- Linux系统邮件查看及清空
- 第六章 编程练习 6.1
- MVC Kendo总结之-----> CheckBox
- Android音频录制--AudioRecord