#K75947. Update Participant Scores

    ID: 34532 Type: Default 1000ms 256MiB

Update Participant Scores

Update Participant Scores

In this problem, you are given the number of participants and a series of score update actions related to a drawing contest. Each action affects the score of a participant by either adding or deducting points. However, no participant's score can go below zero. In particular, if a deduction would result in a negative score, the score is set to zero. Mathematically, if a participant currently has a score s and a deduction of z points is applied, the new score is computed as $$ s = \max(0, s - z) $$. Your task is to calculate and output the final scores of all participants after processing all the actions.

inputFormat

The input is provided from standard input (stdin) and has the following format:

The first line contains two integers n and m, where n is the number of participants and m is the number of actions.

This is followed by m lines, each describing an action with three values separated by spaces:

  • An integer p representing the 1-indexed position of the participant.
  • A character c which is either '+' to indicate that points are added or '-' to indicate that points are deducted.
  • An integer z denoting the amount of points to be added or deducted.

outputFormat

Output the final scores of each participant in a single line to standard output (stdout). The scores should be separated by a single space in the order from the first participant to the nth participant.## sample

3 5
1 + 10
2 - 5
3 + 20
2 - 15
1 - 5
5 0 20

</p>