Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n;
  10. cin >> n;
  11.  
  12. int *arrayForNumbers = new int[n];
  13. int *arrayForSum = new int[n];
  14.  
  15. for(int i=0; i<n; i++)
  16. {
  17. cin >> arrayForNumbers[i];
  18. //arrayForSum[i] = 1;
  19. }
  20.  
  21. for(int i=0; i<n; i++)
  22. {
  23. int maximum = 0;
  24. for(int j=0; j<i; j++)
  25. {
  26.  
  27. if(arrayForNumbers[j] <= arrayForNumbers[i] && arrayForSum[j] > maximum)
  28. {
  29. maximum = arrayForSum[j];
  30. }
  31.  
  32. }
  33.  
  34. arrayForSum[i] = maximum + 1;
  35.  
  36. }
  37.  
  38. // int mAX = 0;
  39. // for(int i=0; i<n; i++)
  40. // {
  41. // if(arrayForSum[i] > mAX)
  42. // {
  43. // mAX = arrayForSum[i];
  44. // }
  45. // }
  46.  
  47.  
  48. cout << *max_element(arrayForSum, arrayForSum+n) << endl;
  49.  
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement