#C5804. Inventory Operations

    ID: 49494 Type: Default 1000ms 256MiB

Inventory Operations

Inventory Operations

You are given an inventory with n different items. Initially, each item has a given stock level. Then, you must process q operations on the inventory. There are two types of operations:

  • Type 1: Increase the stock of the x-th item by y.
  • Type 2: Decrease the stock of the x-th item by y, ensuring that the stock does not fall below 0. In other words, the update is defined by:</p>

    \( stock[x] = \max(0, stock[x] - y) \)

Your task is to compute the final stock levels of all items after all operations have been processed.

inputFormat

The input is read from stdin and has the following format:

  1. The first line contains two integers: n (the number of items) and q (the number of operations).
  2. The second line contains n integers representing the initial stock levels of each item.
  3. The next q lines each contain three integers t, x, and y where:
    • If t = 1, increase the stock of the x-th item by y.
    • If t = 2, decrease the stock of the x-th item by y, but not below 0.

outputFormat

Output to stdout a single line containing the final stock levels of the n items, separated by spaces.

## sample
5 3
10 20 30 40 50
1 1 5
2 3 15
2 5 55
15 20 15 40 0