#K60652. Update Token Levels

    ID: 31134 Type: Default 1000ms 256MiB

Update Token Levels

Update Token Levels

In this problem, you are given ( n ) players numbered from 1 to ( n ). Each player ( i ) starts with a given number of tokens. Then, you are provided with ( m ) events. Each event is represented by a pair ( (P, L) ), which means that player ( P ) loses ( L ) tokens. A player's token count cannot drop below 0; mathematically, after an event the new token level is ( \max(0, \text{tokens}[P] - L) ). Your task is to compute the final token levels for all players after processing all events.

Example:
Input:
3\n50 60 70\n5\n1 30\n2 50\n3 80\n1 10\n2 20
Output:
10 0 0

inputFormat

The input is given via standard input and consists of the following lines:

  1. A line containing an integer ( n ): the number of players.
  2. A line with ( n ) space-separated integers representing the initial tokens for each player.
  3. A line containing an integer ( m ): the number of events.
  4. ( m ) lines, each containing two space-separated integers ( P ) and ( L ), where ( P ) is the (1-indexed) player number, and ( L ) is the number of tokens the player loses in that event.

outputFormat

Output a single line containing ( n ) space-separated integers representing the final token levels of the players after all events have been processed.## sample

3
50 60 70
5
1 30
2 50
3 80
1 10
2 20
10 0 0