Collection of numbers P50709


Statement
 

pdf   zip

thehtml

Write a program to keep a collection of integer numbers, perhaps with repetitions, while performing the following operations:

  • Sx : Stores a copy of the given number x.
  • A’ : Asks for the greatest number.
  • R’ : Removes the greatest number (one of them, if it is repeated).
  • Ix : Increases the greatest number (one of them, if it is repeated) in x units.
  • Dx : Decreases the greatest number (one of them, if it is repeated) in x units.

Input

Input consists of several operations.

Output

For every query, the current greatest number. Print also an error line for each operation (except storing) when the collection is empty.

Public test cases
  • 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
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python