#K49072. Taco Stock Management
Taco Stock Management
Taco Stock Management
You are given an array representing the stock levels of n products. You will process q queries on these products. There are two types of queries:
- Type 1 (Update): Given as
1 x y
, update the stock of the product at index x to the value y. This operation is mathematically represented as \( stock[x] = y \). - Type 2 (Query): Given as
2 x
, output the current stock of the product at index x.
You are required to print the result of each type 2 query on a new line.
inputFormat
Input is read from stdin and has the following format:
- The first line contains two integers n and q — the number of products and the number of queries.
- The second line contains n integers representing the initial stock values.
- Each of the next q lines represents a query. A query of type 1 is given as "1 x y" (update query) and a query of type 2 is given as "2 x" (retrieval query).
Note: Indexing is zero-based.
outputFormat
Output the answer to each query of type 2 on a new line to stdout. Do not output anything for queries of type 1.## sample
5 3
10 20 30 40 50
2 2
1 2 100
2 2
30
100
</p>