Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Maximum Intervals Overlap
Medium Accuracy: 50.12% Submissions: 11041 Points: 4

Consider a big party where a log register for guest’s entry and exit times is maintained. Find the time at which there are maximum guests at the party. Note that entries in the register are not in any order.  if two events have the same time, then arrival is preferred over the exit.



Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the entry and exit array. Then the next two lines contains the entry and exit array respectively.

Output:
Print the maximum no of guests and the time at which there are maximum guests at the party.

Constraints:
1<=T<=10^5
1<=N<=10^5
1<=entry[i],exit[i]<=10^5

Example:
Input:

2
5
1 2 10 5 5
4 5 12 9 12
7
13 28 29 14 40 17 3 
107 95 111 105 70 127 74 


Output:
3 5
7 40

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Maximum Intervals Overlap

Output Window