解题思路:
注意事项:
参考代码:
#include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<ctime> #include<cctype> #include<algorithm> #include<cstring> #include<string> using namespace std; const int N=100005; int dp[N],ans=0,n,num; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&num); int left=1,right=ans; while(left<=right) { int mid=(left+right)/2; if(num<=dp[mid]) right=mid-1; else left=mid+1; } if(left>ans) ans++; dp[left]=num; } cout<<ans<<endl; return 0; }
0.0分
2 人评分