velimir

NajdolgaRasteckaNiza

Feb 26th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x, i, j, maxi=0;
  8.     cin >> x;
  9.     int niza[x], vrednost[x];
  10.     vrednost[x] = {0};
  11.     for(i=0; i<x; i++) cin >> niza[i];
  12.     vrednost[0] = 1;
  13.     for(i=1; i<x; i++)
  14.     {
  15.         maxi = 0;
  16.         for(j=i-1; j>=0; j--)
  17.         {
  18.             if(niza[i]>niza[j] and vrednost[j]>maxi) maxi = vrednost[j];
  19.         }
  20.         vrednost[i] = maxi + 1;
  21.     }
  22.     maxi = 0;
  23.     for(i=0; i<x; i++)
  24.     {
  25.         if(vrednost[i]>maxi)maxi = vrednost[i];
  26.     }
  27.     cout << maxi;
  28.     //cout << vrednost[i] << "   ";
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment