fork download
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4.  
  5. void f(int arrl[], int exit[], int n)
  6. {
  7. sort(arrl, arrl+n);
  8. sort(exit, exit+n);
  9.  
  10. int cur = 1, ans = 1, time = arrl[0];
  11. int i = 1, j = 0;
  12. while (i < n && j < n)
  13. {
  14. if (arrl[i] <= exit[j])
  15. {
  16. cur++;
  17.  
  18. if (cur > ans)
  19. {
  20. ans = cur;
  21. time = arrl[i];
  22. }
  23. i++;
  24. }
  25. else
  26. {
  27. cur--;
  28. j++;
  29. }
  30. }
  31.  
  32. cout << ans;
  33. }
  34.  
  35. const int N = 1e5+1;
  36. int a[N],b[N];
  37. int n;
  38.  
  39.  
  40. int main() {
  41. cin >> n;
  42. for(int i = 0;i < n;i++)cin >> a[i] >> b[i];
  43. f(a,b, n);
  44. return 0;
  45. }
Success #stdin #stdout 0s 16016KB
stdin
Standard input is empty
stdout
1