fork download
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3. #define ll long long int
  4.  
  5.  
  6. int main() {
  7. vector<ll>start;
  8. vector<ll>last;
  9.  
  10. for(int i=1;i<=9;i++)
  11. {
  12. int u,v; cin>>u>>v;
  13. start.push_back(u);
  14. last.push_back(v);
  15. }
  16. sort(start.begin(),start.end());
  17. sort(last.begin(),last.end());
  18.  
  19. int p = 5;
  20. ll d=lower_bound(start.begin(),start.end(),p+1)-start.begin();
  21. ll u=upper_bound(last.begin(),last.end(),p-1)-last.begin();
  22. u=last.size()-u;
  23. cout<<d<<" "<<u<<endl;
  24. ll get=min(d,u);
  25. cout<<"number of segments which cross point"<<p<<" is "<< get<<endl;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5312KB
stdin
1 1
1 2
2 2
3 3
1 5
6 6
7 7
8 8
8 9
stdout
5 5
number of segments which cross point5 is 5