Casino P40902


Statement
 

pdf   zip

html

Write a program to compute the profits of the players of a casino. The operations that can be done are: enter the casino, leave the casino, or win a quantity (maybe negative) of money.

Input

Input consists of several operations. If a player enters the casino, we have his name followed by “enters”. If a player leaves the casino, we have his name followed by “leaves”. When a player wins a quantity (maybe negative), we have his name followed by “wins” followed by the quantity of money won (an integer number).

Output

Every time that a player leaves the casino, print the total quantity of money that he or she has won (it can be negative).

At the end, print a line with 10 dashes, followed by a list sorted by name of the profits of the players that did not left yet. Print also an error line for each incorrect operation, that is, entering the casino when the player is already inside, or leaving or winning money when the player has not entered yet.

Public test cases
  • Input

    Anna enters
    Anna wins 50
    Anna wins -200
    Anna leaves
    Omer enters
    Jordi enters
    Omer wins 100
    Miquel enters
    Omer wins -40
    Omer leaves
    Jordi wins 30
    Omer enters
    Omer wins -20
    

    Output

    Anna has won -150
    Omer has won 60
    ----------
    Jordi is winning 30
    Miquel is winning 0
    Omer is winning -20
    
  • Input

    Amalia leaves
    Berta wins 3
    Cristina enters
    Cristina wins 7
    Cristina enters
    Cristina leaves
    Cristina leaves
    

    Output

    Amalia is not in the casino
    Berta is not in the casino
    Cristina is already in the casino
    Cristina has won 7
    Cristina is not in the casino
    ----------
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python