#C10284. Subarray Increment Queries

    ID: 39472 Type: Default 1000ms 256MiB

Subarray Increment Queries

Subarray Increment Queries

You are given an array of length \(N\) that is initially filled with zeros. You will also be given \(Q\) queries. Each query consists of three integers \(L\), \(R\), and \(X\). For every query, you need to increment each element from index \(L\) to \(R\) (inclusive) by \(X\).

Input/Output Requirements: The input is read from standard input (stdin) and the output must be printed to standard output (stdout). Use appropriate input/output methods for your programming language.

Constraints:

  • \(1 \leq N \leq 10^5\)
  • \(0 \leq Q \leq 10^5\)
  • \(1 \leq L \leq R \leq N\)
  • \(1 \leq X \leq 10^9\)

After processing all the queries, print the final state of the array as a sequence of space-separated integers.

inputFormat

The first line contains two integers \(N\) and \(Q\) separated by a space.

The next \(Q\) lines each contain three integers \(L\), \(R\), and \(X\) separated by spaces, representing a query.

outputFormat

Output a single line containing \(N\) space-separated integers, which represent the final state of the array after all queries have been processed.

## sample
5 3
1 3 2
2 4 3
1 5 1
3 6 6 4 1