POJ 2533
来源:互联网 发布:迅联食材配送软件 编辑:程序博客网 时间:2024/05/17 07:59
Longest Ordered Subsequence
Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 28473 Accepted: 12361
Description
A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i1 < i2< ... < iK <= N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, e. g., (1, 7), (3, 4, 8) and many others. All longest ordered subsequences are of length 4, e. g., (1, 3, 5, 8).
Your program, when given the numeric sequence, must find the length of its longest ordered subsequence.
Your program, when given the numeric sequence, must find the length of its longest ordered subsequence.
Input
The first line of input file contains the length of sequence N. The second line contains the elements of sequence - N integers in the range from 0 to 10000 each, separated by spaces. 1 <= N <= 1000
Output
Output file must contain a single integer - the length of the longest ordered subsequence of the given sequence.
Sample Input
71 7 3 5 9 4 8
Sample Output
4
Source
Northeastern Europe 2002, Far-Eastern Subregion
最裸的LIS了 ,直接1Y秒掉
#include <cstdio>#include <cmath>#include <algorithm>#include <iostream>#include <cstring>#include <map>#include <string>#include <stack>#include <cctype>#include <vector>#include <queue>#include <set>#include <iomanip>using namespace std;//#define Online_Judge#define outstars cout << "***********************" << endl;#define clr(a,b) memset(a,b,sizeof(a))#define lson l , mid , rt << 1#define rson mid + 1 , r , rt << 1|1#define FOR(i , x , n) for(int i = (x) ; i < (n) ; i++)#define FORR(i , x , n) for(int i = (x) ; i <= (n) ; i++)#define REP(i , x , n) for(int i = (x) ; i > (n) ; i--)#define REPP(i ,x , n) for(int i = (x) ; i >= (n) ; i--)#define mk make_pairconst int inf = 1 << 30;const int MAXN = 1000 + 150;const int maxw = 100 + 20;const int MAXNNODE = 1000 +10;const long long LLMAX = 0x7fffffffffffffffLL;const long long LLMIN = 0x8000000000000000LL;const int INF = 0x7fffffff;const int IMIN = 0x80000000;#define eps 1e-8#define mod 20071027typedef long long LL;const double PI = acos(-1.0);typedef double D;typedef pair<int , int> pii;const D e = 2.718281828459;int dp[MAXN];int main(){ //ios::sync_with_stdio(false);#ifdef Online_Judge freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);#endif // Online_Judge int n , num; while(~scanf("%d", & n)) { dp[0] = -1; int top = 0; FOR(i , 0, n) { cin >>num; if(num > dp[top]) { dp[++top] = num; } else { int R = top , L = 1 ; while(L <= R) { int mid = (L + R)/ 2; if(num > dp[mid])L = mid + 1; else R = mid - 1; } dp[L] = num; } } printf("%d\n" , top); } return 0;}
- POJ 2533
- POJ 2533
- POJ 2533
- poj 2533
- POJ 2533
- poj-2533
- poj--2533
- poj 2533
- POJ 2533
- POJ 2533
- POJ 2533
- poj 2533
- POJ-2533
- POJ 2533
- POJ 2533
- POJ 2533
- POJ 2533 O(NLogN)
- poj 2533 LCS
- CHM文档制作
- 变频器开关电源电路实例
- [小说]魔王冢(37)节外生枝
- Java AWT编程笔记-基本元素
- Android中的几种网络请求方式详解
- POJ 2533
- 谷歌眼镜尚未大规模上市,谷歌就已经为它准备好了广告工具
- 40多个关于人脸检测/识别的API、库和软件
- Hql的fetch
- 请立即停止刷博客流量
- 模板元编程 运行时 编译期
- 数据公钥加密和认证中的私钥公钥
- 新的开源引擎 基于C++的记录
- MyReport.TD套打引擎1.0.4.0主要新功能