Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Mihai Bunget
- #include <fstream>
- #include <algorithm>
- #include <set>
- #define N 50001
- using namespace std;
- ifstream f("umede.in");
- ofstream g("umede.out");
- struct pct{int x1,x2,y;} p[N];
- int n,i,x,y,umede,xmax,maxim,ok,nr;
- int locuri[N];
- pair<int,int> sir[2*N];
- set<int> s;
- set<int>::iterator it;
- bool cmp(pct a, pct b)
- {
- return a.y > b.y;
- }
- int main()
- {
- f >> n;
- for(i = 1; i <= n; i++)
- f >> p[i].x1 >> p[i].x2 >> p[i].y;
- sort(p+1, p+n+1, cmp);
- f >> x >> y;
- s.insert(x);
- for(i = 1; i <= n; i++)
- {
- it = s.lower_bound(p[i].x1);
- if(it != s.end())
- {
- if((*it) <= p[i].x2){
- umede++;
- locuri[umede] = i;
- ok = 1;
- while(ok)
- {
- ok = 0;
- s.erase(it);
- it = s.lower_bound(p[i].x1);
- if(it != s.end())
- if((*it)<=p[i].x2)
- ok = 1;
- }
- s.insert(p[i].x1);
- s.insert(p[i].x2);
- }
- }
- }
- g << n-umede << "\n";
- for(i = 1; i <= umede; i++)
- {
- sir[2*i-1] = {p[locuri[i]].x1, 1};
- sir[2*i] = {p[locuri[i]].x2, 2};
- }
- sort(sir+1, sir+2*umede+1);
- maxim = 0;
- nr = 0;
- for(i = 1; i <= 2*umede; i++)
- {
- if(sir[i].second == 1)
- nr++;
- else nr--;
- maxim = max(maxim,nr);
- }
- g << maxim;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement