Collection of numbers P14998


Statement
 

pdf   zip

html

Your task is to write a program that mantains a collection of integer numbers, possibly repeated, and that does the operation according to the indications of the user:

  • S x: Stores a copy of the number x given.
  • C: Consults the greatest number of the collection.
  • D: Deletes the greatest number of the collection (one of them, if it is repeated).
  • I x: Increases the greatest number (one of them, if it is repeated) in x units.
  • D x: Decreases the greatest number (one of them, if it is repeated) in x units.

Input

The input consists of a sequence of orders as the described ones, each one in a line.

Output

For each done query, your program must print in a line the greatest number in that moment. Also, it must print an error line for each operation (except the store operation) when the collection does not have any number, following the format of the instance.




Hint: Notice that the collection can have repeated elements. Moreover, is necessary that your solution is very fast: if you have never used heaps (priority_queue) or (map), you should take advantage to learn. Perhaps asking in the forum... (when the contest ends, of course).

Author: Salvador Roura

Public test cases
  • Input

    C
    G 10    C
    G -7    C
    G 20    C
    I 3     C
    D 15    C
    E       C
    G 30    C
    D 37    E     C
    E       C
    E
    I 1
    C
    E
    D 3
    G 4
    C
    

    Output

    error: no elements
    10
    10
    20
    23
    10
    8
    30
    -7
    -7
    error: no elements
    error: no elements
    error: no elements
    error: no elements
    4
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++