Advertisement
ke_timofeeva7

нвп

Sep 14th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. int n;
  2.     cin >> n;
  3.  
  4.     for (int i = 0; i < n; i++)
  5.     {
  6.         cin >> mas[i];
  7.     }
  8.  
  9.     dp[0] = 1;
  10.  
  11.  
  12.     int num = 0;
  13.  
  14.     for (int i = 1; i < n; i++)
  15.     {
  16.         dp[i] = 1;
  17.         for (int j = 0; j < i; j++)
  18.         {
  19.             if (mas[j] < mas[i])
  20.             {
  21.                 dp[i] = max(dp[i], dp[j] + 1);
  22.             }
  23.         }
  24.     }
  25.  
  26.     int ans = dp[0];
  27.     for (int i = 1; i < n; i++)
  28.     {
  29.         ans = max(ans, dp[i]);
  30.     }
  31.  
  32.     cout << ans;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement