1 #include <iostream> 2 using namespace std; 3 #include <cstdio> 4 5 const int MaxN=100001; 6 7 int n,i,top=0,x,stack[MaxN]; 8 9 int main(){ 10 cin>>n; 11 stack[top]=-1; 12 for(i=1;i<=n;i++){ 13 cin>>x; 14 if(x>stack[top]){stack[++top]=x;} 15 else 16 { 17 int low=0,high=top,mid; 18 while(low<high){ 19 mid=(low+high)>>1; 20 if(x>stack[mid]) 21 low=mid+1; 22 else 23 high=mid-1; 24 } 25 stack[low]=x; 26 } 27 } 28 cout<<top; 29 return 0; 30 }
LIS(单调队列优化)
猜你喜欢
转载自www.cnblogs.com/t-s-y/p/10322100.html
今日推荐
周排行