poj2533
来源:互联网 发布:电脑软件交流群 编辑:程序博客网 时间:2024/05/18 02:39
典型的lis水题一道。重点要掌握lis和lds的0(nlogn)算法,直接贴代码:160K+16MS
#include <stdio.h>#include <stdlib.h>#define Max 1010#define Inf 1000010int a[Max];int c[Max];int n;int Binary_search(int value){int left=0,right=n+1,mid;while(left<=right){mid=(left+right)>>1;if(c[mid]<value)left=mid+1;else if(c[mid]>value)right=mid-1;elsereturn mid;}return left;}int lis(){c[0]=-Inf;c[1]=a[1]; int i,j,result=1;for(i=2;i<=n;i++)c[i]=Inf;for(i=2;i<=n;i++){j=Binary_search(a[i]);c[j]=a[i];if(j>result)result=j;}return result;}int main(){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);printf("%d\n",lis());return 0;}
0 0
- poj2533
- POJ2533
- poj2533
- poj2533
- poj2533
- POJ2533
- poj2533
- POJ2533
- poj2533
- poj2533--LIS
- poj2533 LongestOrderedSubsequence
- poj2533(LIS)
- poj2533 LIS
- POJ2533(LIS)
- poj2533解题报告
- poj2533解题报告
- poj2533 简单DP LIS
- poj2533(最长递增序列)
- POJ 2993 Emag eht htiw Em Pleh 模拟
- 【POJ】1733 Parity game 并查集
- Linux设备驱动的class(类)的理解(以timed_output为基础)
- 兼容sdk7&iOS7的issue解决小片段总结
- 【水hash】#37 A. Towers
- poj2533
- Linux 标准目录结构
- 2-Objective-C 编程
- UVALive 6557 Stampede!(最大流)
- STL使用
- 章鱼搜索网启用域名32.com上线 价格百万美元?
- 多源最短路径弗洛伊德算法(java)不含具体路径
- 生活-个人管理-请不要在睡前惩罚白天的自己
- 聚类分析中几种算法的比较