fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. //#define LOCAL
  4. #define cls ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
  5. #define Mod 998244353
  6. #define ll long long int
  7. #define sf scanf
  8. #define pf printf
  9. #define rep(i,a,b) for(int i=a;i<b;i++)
  10. #define dec(i,a,b) for(int i=b;i>=a;i--)
  11. #define mset(a,b) memset(a,b,sizeof(a))
  12. #define max(a,b) a>b?a:b
  13. const int maxn=2333;
  14. int a[maxn];
  15. int LIS(int n){
  16. if(n==1)
  17. return 1;
  18. int res,max_ending_here=1;
  19. rep(i,1,n){
  20. res=LIS(i);
  21. if(a[i-1]<a[n-1]&&max_ending_here<res+1){
  22. max_ending_here=res+1;
  23. }
  24. }
  25. return max_ending_here;
  26. }
  27. int main(){
  28. cls;
  29. int n;
  30. cin>>n;
  31. rep(i,0,n){
  32. cin>>a[i];
  33. }
  34. cout<<LIS(n)<<endl;
  35. }
  36.  
Success #stdin #stdout 0s 15240KB
stdin
8
10 22 9 33 21 59 41 69
stdout
5