-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBYTESE2.cpp
More file actions
35 lines (34 loc) · 868 Bytes
/
Copy pathBYTESE2.cpp
File metadata and controls
35 lines (34 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int T, N, i, j, c, max_dancers;
cin>>T;
while(T--){
cin>>N;
int entry_time[N], exit_time[N];
for(i=0; i<N; i++)
cin>>entry_time[i]>>exit_time[i];
sort(entry_time, entry_time+N);
sort(exit_time, exit_time+N);
i=0; j=0; c=0; max_dancers=0;
while(i<N && j<N){
if(entry_time[i]==exit_time[j]){
i++;
j++;
}
else if(entry_time[i]<exit_time[j]){
c++;
if(max_dancers<c)
max_dancers=c;
i++;
}
else{
c--;
j++;
}
}
cout<<max_dancers<<"\n";
}
return 0;
}