Problem Description

You will receive q commands: ADD x or MEDIAN. Create MedianFinder class using two heaps. For MEDIAN output lower median (floor for even count).

Input Format

First line q. Next q lines commands.

Output Format

Outputs for MEDIAN.

Sample Test Case

Input:
7 ADD 5 ADD 2 MEDIAN ADD 10 ADD 1 MEDIAN MEDIAN
Output:
2 2 2

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next