#C10039. AutoMart Inventory Management

    ID: 39200 Type: Default 1000ms 256MiB

AutoMart Inventory Management

AutoMart Inventory Management

AutoMart is a vehicle dealership that maintains an inventory of vehicles. Each vehicle has a manufacturer name (make), model (model), manufacturing year (year), and price (price). Your task is to implement an inventory management system that processes a series of operations and outputs the result for each query operation.

The system supports the following operations:

  • add <make> <model> <year> <price>: Adds a vehicle to the inventory.
  • remove <make> <model>: Removes the first vehicle with the specified make and model from the inventory. Print True if removal was successful and False otherwise.
  • value: Outputs the total value of all vehicles in the inventory. Mathematically, if there are n vehicles with prices \(p_1, p_2, \dots, p_n\), then the total value is \(\sum_{i=1}^n p_i\).
  • count <make>: Outputs the number of vehicles in the inventory that have the specified make.

The operations are provided through standard input and the corresponding results for remove, value, and count commands should be printed to standard output, each on a separate line.

inputFormat

The input begins with an integer Q representing the number of operations. The next Q lines each contain an operation. The operations are one of the following:

  • add <make> <model> <year> <price>
  • remove <make> <model>
  • value
  • count <make>

All tokens are separated by spaces. year and price are integers.

outputFormat

For each operation that produces an output (remove, value, count), print the result on a separate line in standard output. For remove, print either True or False (case sensitive). For value and count, print an integer.

## sample
8
add Toyota Corolla 2018 15000
add Honda Civic 2020 20000
add Toyota Camry 2019 18000
value
count Toyota
remove Honda Civic
value
count Honda
53000

2 True 33000 0

</p>