Advertisement
a53

umede

a53
Jan 20th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //Mihai Bunget
  2. #include <fstream>
  3. #include <algorithm>
  4. #include <set>
  5. #define N 50001
  6. using namespace std;
  7. ifstream f("umede.in");
  8. ofstream g("umede.out");
  9. struct pct{int x1,x2,y;} p[N];
  10. int n,i,x,y,umede,xmax,maxim,ok,nr;
  11. int locuri[N];
  12. pair<int,int> sir[2*N];
  13. set<int> s;
  14. set<int>::iterator it;
  15.  
  16. bool cmp(pct a, pct b)
  17. {
  18. return a.y > b.y;
  19. }
  20.  
  21. int main()
  22. {
  23. f >> n;
  24. for(i = 1; i <= n; i++)
  25. f >> p[i].x1 >> p[i].x2 >> p[i].y;
  26. sort(p+1, p+n+1, cmp);
  27. f >> x >> y;
  28. s.insert(x);
  29. for(i = 1; i <= n; i++)
  30. {
  31. it = s.lower_bound(p[i].x1);
  32. if(it != s.end())
  33. {
  34. if((*it) <= p[i].x2){
  35. umede++;
  36. locuri[umede] = i;
  37. ok = 1;
  38. while(ok)
  39. {
  40. ok = 0;
  41. s.erase(it);
  42. it = s.lower_bound(p[i].x1);
  43. if(it != s.end())
  44. if((*it)<=p[i].x2)
  45. ok = 1;
  46. }
  47. s.insert(p[i].x1);
  48. s.insert(p[i].x2);
  49. }
  50. }
  51. }
  52. g << n-umede << "\n";
  53. for(i = 1; i <= umede; i++)
  54. {
  55. sir[2*i-1] = {p[locuri[i]].x1, 1};
  56. sir[2*i] = {p[locuri[i]].x2, 2};
  57. }
  58. sort(sir+1, sir+2*umede+1);
  59. maxim = 0;
  60. nr = 0;
  61. for(i = 1; i <= 2*umede; i++)
  62. {
  63. if(sir[i].second == 1)
  64. nr++;
  65. else nr--;
  66. maxim = max(maxim,nr);
  67. }
  68. g << maxim;
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement