#K43472. Store Inventory Management
Store Inventory Management
Store Inventory Management
A store sells \(N\) types of fruits and manages its inventory using a series of operations. Each fruit has an associated price and quantity. The store performs three types of operations:
- Update Price: Change the price of a specific fruit.
- Update Quantity: Change the quantity of a specific fruit.
- Calculate Value: Compute the total value of a fruit's inventory using the formula \(P \times Q\), where \(P\) is the price and \(Q\) is the quantity.
Your task is to process a series of operations and output the result of each value calculation operation.
Note: The fruits are numbered from 1 to \(N\). Operations that update either price or quantity do not produce any output while the calculation operation does.
inputFormat
The input is read from standard input (stdin
) and has the following format:
- An integer \(N\) representing the number of fruit types.
- \(N\) lines follow, each containing two integers: the initial price and quantity for each fruit, from fruit 1 to fruit \(N\).
- An integer \(M\) representing the number of operations.
- \(M\) lines follow, each describing an operation. Each line will be in one of the following formats:
1 x p
: Update the price of fruit \(x\) to \(p\).2 x q
: Update the quantity of fruit \(x\) to \(q\).3 x
: Calculate and output the current total value (i.e. \(price[x] \times quantity[x]\)) of fruit \(x\).
outputFormat
For each operation of the type 3 x
, output the total value of the corresponding fruit on a separate line. If no calculation operation occurs, nothing should be printed.
3
10 5
20 8
15 10
5
1 2 25
3 2
2 1 7
3 1
3 3
200
70
150
</p>