hdu 1025 Constructing Roads In JGShining's Kingdom
来源:互联网 发布:淘宝李白凤求凰可信吗 编辑:程序博客网 时间:2024/04/29 16:47
链接:点击打开链接
经典DP,最长递增子序列(要用NLogN的方法过)
#include"stdio.h"int num[500011];int ans[500011];int main(){ int n,k=1; int len,low,up,mid; int i; int temp1,temp2; while(scanf("%d",&n)!=-1) { for(i=0;i<n;i++) { scanf("%d%d",&temp1,&temp2); num[temp1]=temp2; } ans[1]=num[1]; len=1; for(i=2;i<=n;i++) { /*****/ //这个二分是别人写的,表示比我写的好多了- -I。 low=1; up=len; while(low<=up) { mid=(low+up)/2; if(ans[mid]<num[i]) low=mid+1; else up=mid-1; } ans[low]=num[i]; if(low>len) len++; /*****/ } printf("Case %d:\n",k); if(len==1) printf("My king, at most 1 road can be built."); else printf("My king, at most %d roads can be built.",len); printf("\n"); printf("\n"); k++; } return 0;}
- hdu Constructing Roads In JGShining's Kingdom
- hdu 1025Constructing Roads In JGShining's Kingdom(LIS)
- 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
- HDU 1025 Constructing Roads In JGShining's Kingdom DP+二分
- Hdu 1025 - Constructing Roads In JGShining's Kingdom
- hdu 1025 Constructing Roads In JGShining's Kingdom
- hdu 1025 Constructing Roads In JGShining's Kingdom(LIS)
- HDU 1025 Constructing Roads In JGShining's Kingdom
- hdu 1025 Constructing Roads In JGShining's Kingdom (DP + 二分)
- 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 (LIS)
- HDU - 1025 Constructing Roads In JGShining's Kingdom
- HDU 1025 Constructing Roads In JGShining's Kingdom
- 2011级-csdn-java-张侃—Spring(2)
- BlazeDS
- C#迭代器,枚举器
- ComboBox控件 详解1
- 查看图片前进后退效果图
- hdu 1025 Constructing Roads In JGShining's Kingdom
- Hibernate插入、查询、删除操作
- 在线进销存管理系统源码 客户关系管理系统源码 人事薪资管理系统源码(PHP+MySQL)
- <jsp:include>能include静态页面吗?
- JDBC中编写的经典通用的工具类
- 扫盲贴(二)----------------------专业术语
- Respond.js
- jQuery邮箱验证
- 给程序员推荐几部电影