#C8360. Shopping Cart Manager

    ID: 52334 Type: Default 1000ms 256MiB

Shopping Cart Manager

Shopping Cart Manager

You are required to implement a simple shopping cart manager. The cart supports three operations:

  • add — Add an item to the cart with a unique identifier and a price.
  • remove — Remove an item from the cart by its identifier.
  • total — Compute the total price of all items currently in the cart.

When computing the total price, use the formula: \(T = \sum_{i=1}^{n} price_i \), where \(price_i\) is the price of the \(i^{th}\) item in the cart.

The input will specify a sequence of operations. The operations are processed sequentially and exactly one "total" command will be issued that requests the final total price to be printed.

inputFormat

The first line of input contains an integer \(N\) representing the number of operations. The following \(N\) lines each contain an operation.

An operation is in one of the following formats:

  • add item_id price — add an item with identifier item_id and cost price.
  • remove item_id — remove the item with identifier item_id if it exists.
  • total — output the sum of prices of all items currently in the cart.

Each item_id and price is an integer. It is guaranteed that the total operation appears exactly once and is the final command.

outputFormat

Output a single integer which is the total price of all items in the cart after processing all operations.

## sample
3
add 101 20
add 102 40
total
60