标签:
1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 #include<iostream> 5 #include<algorithm> 6 #include<queue> 7 #include<vector> 8 #include<set> 9 #include<stack> 10 #include<string> 11 #include<sstream> 12 #include<map> 13 #include<cctype> 14 #include<limits.h> 15 using namespace std; 16 int main() 17 { 18 int n,b,dp[100005],location,num; 19 while(scanf("%d",&n)!=EOF) 20 { 21 num=0; 22 for(int i=0;i<n;i++) 23 { 24 scanf("%d",&b); 25 location=lower_bound(dp,dp+num,b)-dp; //在 已经有序的数组中二分查找 26 dp[location]=b; 27 num=location+1>num?location+1:num; 28 } 29 printf("%d\n",num); 30 } 31 return 0; 32 }
标签:
原文地址:http://www.cnblogs.com/A-FM/p/5426987.html