Write a program to keep a collection of integer numbers, perhaps with repetitions, while performing the following operations:
‘S’
: Stores a copy of the given number
.
‘A’ : Asks for the greatest number.
‘R’ : Removes the greatest number (one of them, if
it is repeated).
‘I’
: Increases the greatest number (one of them, if it is repeated) in
units.
‘D’
: Decreases the greatest number (one of them, if it is repeated) in
units.
Input consists of several operations.
For every query, the current greatest number. Print also an error line for each operation (except storing) when the collection is empty.
Input
A S 10 A S -7 A S 20 A I 3 A D 15 A R A S 30 A D 37 R A R A R I 1 A R D 3 S 4 A
Output
error! 10 10 20 23 10 8 30 -7 -7 error! error! error! error! 4