The original title
Topic analysis
It is known by the subject, if possible to find the longest increasing subsequence connection point, the connection can not point in the sequence of all the cut line, while maintaining the longest increasing subsequence dp can be done, taking into account the same length incrementing the last digit sequences as small as possible, can be defined dp, dp [i] is the minimum length of the end value of i is incremented sequence, the initialization is INF, since this has the orderly dp, it can be used to speed bipartite updating the value of each iteration to the num [i], only half of greater than or equal to find num [i] updates the last scan can be obtained from the longest length dp array again.
Code
1 #include <iostream> 2 #include <algorithm> 3 #include <utility> 4 #include <cstdio> 5 #include <cmath> 6 #include <cstring> 7 #include <string> 8 #include <vector> 9 #include <stack> 10 #include <queue> 11 #include <map> 12 #include <set> 13 14 using namespace std; 15 typedef long long LL; 16 const int INF_INT=0x3f3f3f3f; 17 const LL INF_LL=0x3f3f3f3f3f3f3f3f; 18 19 int dp[50000]; 20 21 int main() 22 { 23 // freopen("black.in","r",stdin); 24 // freopen("black.out","w",stdout); 25 int t; 26 cin>>t; 27 while(t--) 28 { 29 int n; 30 cin>>n; 31 for(int i=0;i<=n;i++) dp[i]=INF_INT; 32 for(int i=0;i<n;i++) 33 { 34 int x; 35 scanf("%d",&x); 36 *lower_bound(dp,dp+n,x)=x; 37 } 38 // for(int i=0;i<n;i++) printf("dp[%d]=%d\n",i,dp[i]); 39 int ans=0; 40 while(dp[ans]!=INF_INT) ans++; 41 cout<<ans<<endl; 42 } 43 return 0; 44 }