Description of the problem: Given a number of columns of length K A, up to find the value of a monotonically increasing sequence length is. Any sub-sequence B A can be expressed as B = {Ak1, Ak2, ...}, where k1 <k2 <....
State means: b [i] represents the length of A [i] is the end of the "rise longest sequence" of
Phasing: the end position of the sub sequence (position A in series, front to back)
Transfer equation: b [i] = max {b [j] +1} (0≤j <i, A [j] <A [i])
Border: b [0] = 0
Target: max {b [i]} 1≤i≤N
Code:
#include<bits/stdc++.h> using namespace std; int k; int a[11011]; int b[11011]; int ans; int main(){ cin>>k; for(int i=1;i<=k;i++){ cin>>a[i]; } for(int i=1;i<=k;i++){ for(int j=1;j<i;j++){ if(a[i]>a[j]){ b[i]=max(b[i],b[j]); } } b[i]++; ans=max(ans,b[i]); } cout<<ans<<endl; return 0; }