Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <fstream>
  2. #define nmax 1005
  3.  
  4. //NU UITA SA MODIFICI DATELE, NMAX SI .in .out
  5.  
  6. using namespace std;
  7.  
  8. ifstream f("subsiruri.in");
  9. ofstream g("subsiruri.out");
  10.  
  11. int l[nmax], a[nmax], n, lmax, nr[nmax], poz, nr2;
  12.  
  13. int main()
  14. {
  15. int i, j, max;
  16. f>>n;
  17. for(i=1;i<=n;++i) f>>a[i];
  18. l[n]=1;
  19. for(i=n-1;i>=1;--i)
  20. {
  21. max=nr2=0;
  22.  
  23. for(j=i+1;j<=n;++j)
  24. if(l[j]>max && a[j]>a[i])
  25. max=l[j];
  26.  
  27. for(j=i+1;j<=n;++j) if(l[i]==max) ++nr2;
  28.  
  29. nr[i]=nr[i-1]+nr2;
  30. l[i]=max+1;
  31.  
  32. if(l[i]>lmax)
  33. {
  34. lmax=l[i];
  35. poz=i;
  36. }
  37. }
  38.  
  39. //for(i=1;i<=n;++i)
  40. //g<<l[i]<<" ";
  41.  
  42. g<<nr[1];
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement