Median in a stream of numbers

My code is working for given test data but fails for some others that i tried.

What is going wrong in the code?Can you correct it?

@aryamaan1011
There are few mistakes in your code

  1. Your first and second priority_queue are declared outside while(t–). So it consist data from previous testcase. Either declare them inside while loop or clear them at the end of each testcase.
  2. For testacase you have to print ans in separate line but your code is printing them in same line. Move cout<<endl; ouside for loop

I made the corrections u told but its still showing wrong answer??

https://ide.codingblocks.com/s/264379 Here is the link of the revised code