#C1196. Inventory Management System
Inventory Management System
Inventory Management System
You are given an inventory management system that handles various types of widgets. Initially, there are n types of widgets, and their quantities are provided. Then, you will perform q operations on the inventory. The operations are given in the following format:
(
1\ x\ y: Add y widgets to the x-th type of widget.
2\ x\ y: Remove y widgets from the x-th type of widget.
3\ x\ y: Query the total number of widgets from the x-th to the y-th type (inclusive).
)
The operations are performed sequentially. For each query operation (operation of type 3), output the resulting sum on a new line.
Note: The widget types are numbered starting from 1.
inputFormat
Input is read from standard input (stdin). The first line contains two integers n and q (the number of widget types and the number of operations, respectively). The second line contains n integers representing the initial quantities of the widgets. Each of the next q lines contains an operation in one of the following formats:
1 x y 2 x y 3 x y
where x and y are integers. Operations of type 1 and 2 modify the inventory, and operations of type 3 require you to print the sum of widgets in the range [x, y].
outputFormat
For every query operation (type 3), output the result on a separate line to standard output (stdout).## sample
5 6
10 5 7 3 8
3 1 3
1 2 4
3 1 3
2 4 1
3 3 5
1 5 2
22
26
17
</p>