BYTESE2  The Great Ball
The Great Ball (5 points) Hogwarts has organized The Great Ball to welcome the schools participating in the Triwizard Tournament. The ball is being held in the Great Hall and The Weird Sisters have been called to play the band. The students drift in to dance and then go out when they get tired. Hagrid is stationed at the gate and is noting down the time at which people enter and leave the hall. At the end of the day, he wonders what the maximum number of dancers was during the course of the ball. For convenience, he writes down for each person entering, the number of minutes from the start of the ball at which the person entered and left. The door of the hall is narrow, so at any time, either one person can enter or one person can exit, but not both. For example, suppose the observations noted down by Hagrid are the following:
Serial No  Enters at  Leaves at 
1  1  7 
2  2  4 
3  6  9 
4  3  8 
5  5  10 
Input
The first line is a single integer, T (1<=T<=100), which is the number of test cases. For each of the test case, the first line contains a single integer N, (1<=N<=100), the number of entries and exits recorded. This is followed by N lines. Each of these lines consists of two integers, separated by a space, describing the entry and exit time of that person. The entry and exit times are guaranteed to be distinct, and the entry time will be less than the exit time. The constraint on entry and exit times is 10000000.
Output
A total of T lines each of them containing a single integer, denoting the maximum number of dancers during the ball.
Example
Input: 1 5 1 7 2 4 6 9 3 8 5 10 Output: 4
hide comments
fardin_abir:
20190928 05:37:47
Can't get it.. why two same code gives different verdict, one gives TLE. After a moment when I resubmit it... it shows AC. 

payal2621:
20190901 18:53:49
maps got ac in 0.00 sec!


nitin_uniyal21:
20190706 13:38:47
Store each entrance and exit as an event (a change in number of people which is +1 or 1, and a time the event occurs). Then process the events in order of time and keep track of the number of people after each event.


prudhvi_495:
20190619 15:33:16
2 pointer!!


klmo:
20190423 15:43:41
Using TreeMap in java to keep entry and exit sorted and linear traversal of entryset to finid maximum count. But still getting TLE. :( Last edit: 20190423 15:43:59 

suyashky:
20190329 18:09:31
Quora turns 0.10s to 0.00s! 

bloodgreed99:
20190307 12:01:37
Too easy with priority queue 

yaseenmollik:
20181115 22:23:39
Could have used Segment tree. But, it is much more easier to solve just using a vector.. 

masterchef2209:
20181025 14:14:46
AC in one go...


faiazamin_040:
20181025 02:42:55
Easy. Just used three arrays.o(n^2).

Added by:  Paritosh Aggarwal 
Date:  20090221 
Time limit:  0.282s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PASGPC PASFPC PERL PHP PIKE PRLGswi PYTHON RUBY SCM qobi SCM guile ST WHITESPACE 