Updating the inventory
The shop has
nitems with different prices. When a customer purchases an item, the shop owner wants to know what would be the cheapest and the most expensive item in the inventory after the purchased item is gone. They ask you to help them with implementing the program that would calculate the cheapest and the most expensive items in the shop after removing each element in the inventory. Note that the removals are independent i.e. for each index we consider only removing that index without touching other elements.
The first line of the input contains an integer
n- the number of items in the shop (1 ≤ n ≤ ).
The next line contains
nintegers separated by a space, that represent the prices of those items .
The program should print
ishould contain two numbers - the cheapest and the most expensive item in the inventory after removing item
5 6 8 1 10 3
1 10 1 10 3 10 1 8 1 10
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 10 MB