fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. int x[100050],dp[100050],n,m,maxx=0;
  5. signed main(){
  6. ios::sync_with_stdio(false);
  7. cin.tie(0),cout.tie(0);
  8. cin>>n;
  9. for(int i=1;i<=n;i++){
  10. cin>>x[i];
  11. }
  12. for(int i=1;i<=n;i++){
  13. dp[i]=1;
  14. }
  15. for(int i=1;i<=n;i++){
  16. for(int j=1;j<=i-1;j++){
  17. if(x[i]<=x[j]){
  18. dp[i]=max(dp[i],dp[j]+1);
  19. }
  20. }
  21. }
  22. for(int i=1;i<=n;i++){
  23. maxx=max(maxx,dp[i]);
  24. }
  25. cout<<maxx;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5320KB
stdin
3
3 2 2
stdout
3