Advertisement
a53

gogosi

a53
Nov 26th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. using namespace std;
  4. ifstream f("gogosi.in");
  5. ofstream g("gogosi.out");
  6. vector<int> a;
  7. int n,x,st,dr,mij;
  8. int main()
  9. {
  10. f>>n;
  11. for(int i=0;i<n;++i)
  12. {
  13. f>>x;
  14. st=0;
  15. dr=a.size()-1;
  16. while(st<=dr)
  17. {
  18. mij=(st+dr)/2;
  19. if(a[mij]<=x)
  20. dr=mij-1;
  21. else
  22. st=mij+1;
  23. }
  24. if(st==(int)a.size())
  25. a.push_back(x);
  26. else
  27. a[st]=x;
  28. }
  29. g<<a.size();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement