Running median using heaps

Can you tell why my code is giving wrong answer? The logic is the same as told in the video. https://ide.codingblocks.com/s/111232

@urvigoel26
Your code is failing for multiple testcases as you are taking more inputs for a testcase than you should. Since you are already taking one input before running the while loop and then taking n more inputs , your single testcase ends up take (n+1) inputs instead of n. This creates a problem and gives incorrect output .
Input :
2
6
5 15 1 3 2 8
6
5 15 1 3 2 8

Expected Output :
5 10 5 4 3 4
5 10 5 4 3 4

Your Output :
5 10 5 4 3 4
15 8 3 2 3

1 Like