#C11857. Warehouse Operations

    ID: 41219 Type: Default 1000ms 256MiB

Warehouse Operations

Warehouse Operations

You are managing a warehouse with N different types of products. Each product has an initial quantity given in an array. Then, you are given M operations to perform sequentially. Each operation is one of the following types:

  • add X Y: Increase the quantity of product X by Y.
  • remove X Y: Decrease the quantity of product X by Y.
  • report X: Print the current quantity of product X.

Note that the product types are numbered from 1 to N. Your task is to execute the operations and generate output for every report operation.

For example, if N = 5 and the initial quantities are [10, 20, 30, 40, 50] with the following operations:

add 3 15
report 3
remove 2 5
report 2
add 5 20
report 5

The output should be:

45
15
70

Make sure your solution reads input from standard input (stdin) and prints the output to standard output (stdout).

inputFormat

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

  1. The first line contains two space-separated integers: N (the number of product types) and M (the number of operations).
  2. The second line contains N space-separated integers representing the initial quantities of the products.
  3. The following M lines each contain an operation in one of the following forms:
    • add X Y
    • remove X Y
    • report X
    Note that X is the product index (1-indexed) and Y is the quantity to add or remove.

outputFormat

For every 'report' operation, output the current quantity of the specified product on a separate line to standard output (stdout).

## sample
5 6
10 20 30 40 50
add 3 15
report 3
remove 2 5
report 2
add 5 20
report 5
45

15 70

</p>