#K16236. Simulate Message Count Updates
Simulate Message Count Updates
Simulate Message Count Updates
You are given n users, each with an initial message count. Then k interactions occur. Each interaction is represented by a pair of integers: a user index (from 0 to n-1) and an integer value (that can be positive or negative) to be added to the corresponding user's message count.
Your task is to simulate these interactions and output the final message counts for all users. Formally, let \(a_i\) (for \(0 \leq i < n\)) be the initial counts and each interaction is of the form \((j, d)\) where you need to update \(a_j := a_j + d\). Finally, you must output the updated list of counts.
Input/Output Specifications: The input will be read from standard input (stdin) and the output must be printed to standard output (stdout).
inputFormat
The first line contains an integer n which indicates the number of users.
The second line contains n space-separated integers representing the initial message counts for each user.
The third line contains an integer k, the number of interactions.
The next k lines each contain two space-separated integers: the first integer is the user index (0-indexed) and the second integer is the change in the message count (which may be negative).
outputFormat
Output a single line containing n space-separated integers, which are the final message counts for the users after all interactions have been applied.
## sample5
10 20 30 40 50
3
0 5
3 -10
2 15
15 20 45 30 50