hdu1025 Constructing Roads In JGShining's Kingdom
来源:互联网 发布:无创dna数据看性别图 编辑:程序博客网 时间:2024/05/20 16:14
思路:读懂题目之后就是一个裸的nlogn的LIS模板题
#include<bits\stdc++.h>using namespace std;const int maxn = 50005;int a[maxn],b[maxn];int bin_search(int aim,int low,int high){while(low<=high){int m = (low+high)>>1;if(aim > b[m])low=m+1;elsehigh = m-1;}return low;}int LIS(int a[],int n){int len = 0,pos;for(int i = 1;i<=n;i++){if(a[i]>b[len]||len==0){len++;b[len]=a[i];}else{pos = bin_search(a[i],0,len);b[pos]=a[i];}}return len;}int main(){ int n,cas=1; while(scanf("%d",&n)!=EOF) { for(int i = 1;i<=n;i++) { int p,t; scanf("%d%d",&p,&t); a[p]=t; } int ans = LIS(a,n); if(ans==1) printf("Case %d:\nMy king, at most %d road can be built.\n\n",cas++,ans); else printf("Case %d:\nMy king, at most %d roads can be built.\n\n",cas++,ans); }}
0 0
- hdu1025 Constructing Roads In JGShining's Kingdom
- HDU1025 Constructing Roads In JGShining's Kingdom
- hdu1025-Constructing Roads In JGShining's Kingdom
- HDU1025 Constructing Roads In JGShining's Kingdom
- HDU1025 Constructing Roads In JGShining's Kingdom
- hdu1025 Constructing Roads In JGShining's Kingdom
- HDU1025 Constructing Roads In JGShining's Kingdom
- hdu1025 Constructing Roads In JGShining's Kingdom
- HDU1025 Constructing Roads In JGShining's Kingdom
- hdu1025 Constructing Roads In JGShining's Kingdom
- hdu1025 Constructing Roads In JGShining's Kingdom
- hdu1025 Constructing Roads In JGShining's Kingdom
- HDU1025 Constructing Roads In JGShining's Kingdom
- HDU1025:Constructing Roads In JGShining's Kingdom(LIS)
- hdu1025 Constructing Roads In JGShining's Kingdom (nlogn的LIS)
- hdu1025 Constructing Roads In JGShining's Kingdom(二分+dp)
- hdu1025 Constructing Roads In JGShining's Kingdom(DP+二分)
- HDU1025:Constructing Roads In JGShining's Kingdom(LIS(dp+二分))
- HDU-4190二分答案
- HBase整合MapReduce之建立HBase索引
- UITextField && UITextView
- 社会实践感悟
- A. Infinite Sequence
- hdu1025 Constructing Roads In JGShining's Kingdom
- 软件开发注意事项
- 2016年5月20日总结
- 软件设计师考试2
- table 行上移 下移 置顶 删除
- 如何监听Tabbar的点击
- 信息框出现位置的理解
- spark分布式安装 spark集群搭建 hadoop集群搭建
- 一个最简单的Servlet服务