Advertisement
Guest User

grigoras

a guest
Nov 19th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("plopi.in");
  6. ofstream fout("plopi1.out");
  7.  
  8. int n,v[1005],L[1005],lmax;
  9.  
  10. void citire()
  11. {
  12. fin>>n;
  13. for(int i=1;i<=n;i++)
  14. fin>>v[i];
  15. }
  16. void plopi()
  17. {
  18. L[n]=1;
  19. for(int i=n-1;i>=1;i--)
  20. {
  21. L[i]=1;
  22. for(int j=i+1;j<=n;j++)
  23. if(v[i]>v[j]&&L[i]<L[j]+1)
  24. L[i]=L[j]+1;
  25. if(L[i]>lmax)
  26. lmax=L[i];
  27. }
  28. }
  29. int main()
  30. {
  31. citire();
  32. plopi();
  33. fout<<n-lmax;
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement