#C6840. Warehouse Stock Management

    ID: 50645 Type: Default 1000ms 256MiB

Warehouse Stock Management

Warehouse Stock Management

In this problem, you are given the initial stock of items in a warehouse along with a series of orders. Each order is either an add operation, which increases the stock of a given item, or a remove operation, which decreases the stock only if the current stock is sufficient. Otherwise, the removal order is ignored.

Your task is to simulate these orders and output the final stock of each item.

Note: If a removal operation asks for more items than available, the stock of that item remains unchanged.

inputFormat

The input is read from stdin and is formatted as follows:

  • The first line contains an integer N representing the number of unique items.
  • The second line contains N space-separated integers representing the initial stock of each item.
  • The third line contains an integer Q representing the number of orders.
  • The following Q lines each contain an order in the format add id x or remove id x, where id is the index of the item (0-indexed) and x is the quantity.

outputFormat

Output a single line to stdout containing N space-separated integers. Each integer represents the final stock of the corresponding item after processing all orders.

## sample
3
10 5 8
5
add 0 5
remove 1 2
add 2 10
remove 0 3
remove 2 20
12 3 18