标签:
http://poj.org/problem?id=3903
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 5983 | Accepted: 2096 |
Description
Input
Output
Sample Input
6
5 2 1 4 5 3
3
1 1 1
4
4 3 2 1
Sample Output
3
1
1
Hint
#include <cstdio> #include <algorithm> #include <cstring> #include<iostream> #include <string> #include <cmath> using namespace std; //LIS+二分优化 O(nlogn) //参考:http://www.cnblogs.com/ziyi--caolu/p/3227121.html int a[100005]; int main() { int n; while(cin>>n){ int k=1,in; scanf("%d",a+1); for(int i=2;i<=n;i++){ scanf("%d",&in); if(in>a[k]) a[++k]=in; else{ int l=1,r=k,mid; while(l<r){ mid=(l+r)/2; if(a[mid]<in) l=mid+1; else r=mid; } a[l]=in; } } cout<<k<<endl; } return 0; }
2016-05-29
POJ 3903:Stock Exchange(裸LIS + 二分优化)
标签:
原文地址:http://www.cnblogs.com/fightfordream/p/5558696.html