标签:
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int stock[100005],dp[100005]; 5 int main() 6 { 7 int n,i,k,left,right,mid; 8 while(scanf("%d",&n)!=EOF) 9 { 10 for(i=0;i<n;i++) 11 scanf("%d",&stock[i]); 12 dp[0]=-1; 13 k=0; 14 for(i=0;i<n;i++) 15 { 16 if(stock[i]>dp[k]) 17 dp[++k]=stock[i]; 18 else 19 { 20 left=1; 21 right=k; 22 while(left<=right) 23 { 24 mid=(left+right)/2; 25 if(stock[i]>dp[mid]) 26 left=mid+1; 27 else 28 right=mid-1; 29 } 30 dp[left]= stock[i]; 31 } 32 33 } 34 printf("%d\n",k); 35 } 36 return 0; 37 }
标签:
原文地址:http://www.cnblogs.com/x512149882/p/4733180.html