Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 300 + 11;
  6.  
  7. int dp[N], a[N];
  8.  
  9. int main()
  10. {
  11. int n;
  12. cin >> n;
  13. for (int i = 0; i < n; i++) {
  14. cin >> a[i];
  15. }
  16. dp[0] = 1;
  17. for (int i = 1; i < n; i++) {
  18. dp[i] = 1;
  19. for (int j = 0; j < i; j++) {
  20. if (a[j] < a[i]) {
  21. dp[i] = max(dp[i], dp[j] + 1);
  22. }
  23. }
  24. }
  25. int ans = -1;
  26. for (int i = 0; i < n; i++) {
  27. ans = max(ans, dp[i]);
  28. }
  29. cout << ans << endl;
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement