#K91667. Tower Defense Simulation

    ID: 38027 Type: Default 1000ms 256MiB

Tower Defense Simulation

Tower Defense Simulation

This problem involves simulating a tower defense scenario. You are given n towers with initial energy levels and a sequence of attacks. Each attack decreases the energy of a contiguous range of towers by a specified amount.

Formally, if there are n towers with energy levels \(E_1, E_2, \dots, E_n\) and an attack is described by three integers \(l\), \(r\), \(d\), then for every tower index \(i\) satisfying \(l \le i \le r\), its energy is updated to \(E_i = E_i - d\). Your task is to compute the final energy levels of all towers after all the attacks are applied.

Note: The indices provided in the attacks are 1-based.

inputFormat

The first line of the input contains two integers n and m, where n is the number of towers and m is the number of attacks.

The second line contains n integers representing the initial energy levels of the towers.

The next m lines each contain three integers \(l\), \(r\), \(d\) that describe an attack (1-based indices), where:

  • \(l\): starting tower index
  • \(r\): ending tower index
  • \(d\): the decrease in energy for each affected tower

outputFormat

Output a single line containing n integers which represent the final energy levels of the towers after processing all attacks. The numbers should be separated by a single space.

## sample
5 3
100 200 150 130 110
1 3 50
2 5 120
3 4 90
50 30 -110 -80 -10

</p>