#K11451. Calculate Final Scores

    ID: 23471 Type: Default 1000ms 256MiB

Calculate Final Scores

Calculate Final Scores

You are given n participants with their initial scores and m operations. Each operation is described by three integers l, r and v. For each operation, you need to add v to the scores of all participants with indices from l to r (inclusive).

The update operation can be mathematically described using the following formula:

$$score_i = score_i + \sum_{\substack{(l,r,v)\\ l \le i \le r}} v $$

Your task is to compute the final scores after applying all the operations sequentially.

inputFormat

The input is provided via standard input (stdin) as follows:

  • The first line contains two integers n and m where n is the number of participants and m is the number of operations.
  • The second line contains n space-separated integers representing the initial scores of the participants.
  • The next m lines each contain three space-separated integers l, r, and v representing an operation that adds v to all scores from participant l to r (1-indexed).

outputFormat

Output a single line to standard output (stdout) containing n space-separated integers representing the final scores of the participants after performing all the operations.

## sample
5 3
1 2 3 4 5
1 3 10
2 5 -5
1 5 3
14 10 11 2 3