Bag of words P84415


Statement
 

pdf   zip

thehtml

You have an initially empty bag, where you can store words, and from where you can delete words. Words can be repeated. Deleting a word means removing one of its appearances. Deleting a nonexistent word does not have any effect. At any moment you can be asked for the (lexicographically) greatest word of the bag, and how many times it is repeated. You can also be asked for the same about the smallest word.

Input

Input consists of several lines. Each line contains either “store w”, where w is a word, or “delete w”, where w is a word, or “maximum?”, or “minimum?”. Every word is made up of only one or more lowercase letters.

Output

For each query, print the greatest word (or the smallest) contained in the bag at that moment. If, at the moment of answering any query, the bag is empty, tell so. Follow the format of the example.

Public test cases
  • Input

    minimum?
    store hi
    minimum?
    delete bye
    store hi
    maximum?
    minimum?
    store bye
    minimum?
    delete bye
    delete hi
    delete hi
    maximum?
    delete hi
    maximum?
    

    Output

    indefinite minimum
    minimum: hi, 1 time(s)
    maximum: hi, 2 time(s)
    minimum: hi, 2 time(s)
    minimum: bye, 1 time(s)
    indefinite maximum
    indefinite maximum
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python