SpongeBob is hungry while waiting the bus. As a vending machine, now you want to sell the median-price kandy to SpongBob.
The Median Price is defined as the price of the element at index [(size - 1) / 2] in the sorted list of kandy prices.
If you have the following kandy prices: [10, 25, 40, 50], whose size is 4 and index is 0-based, then you should sell the kandy at index (size - 1) / 2 = 1.
If you have the following kandy prices: [10, 25, 40, 50, 100], whose size is 5 and index is 0-based, then you should sell the kandy at index (size - 1) / 2 = 2.
This is a partial judge probelm. Please implement these two functions:
store <price>: Add an item with a given price (integer) into the vending machine.
sell: Sell the Median-Price kandy. If the machine is empty, ignore this command.
Constraints
Please note that you CANNOT use STL to solve this problem.
A sequence of commands (store <num> or sell).
A single line containing two integers separated by a space:
The total number of items sold.
The total revenue with '\n'.