Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cstdlib>
- #include<iomanip>
- #include<algorithm>
- using namespace std;
- struct Event {
- int start, end;
- /* bool operator < (const Event &x)const
- {
- return start<x.start;
- } */
- };
- int how_many_rooms (Event* e, int N)
- {
- // sort(e,e+N);
- int maxr=0,r=0,time;
- int i=0,j=0;
- for(i;i<N;i++)
- {
- time=e[i].start;
- while(e[j].end<=time)
- {
- r--;
- j++;
- }
- r++;
- if(r>maxr)maxr=r;
- }
- return maxr;
- }
- int main() {
- int N;
- cin >> N;
- Event e[N];
- for (int i=0; i<N; i++) cin >> e[i].start >> e[i].end;
- cout << how_many_rooms(e, N) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement