#C13264. Inventory Update Function

    ID: 42783 Type: Default 1000ms 256MiB

Inventory Update Function

Inventory Update Function

Implement a function to update an inventory record. You are given an inventory represented as a dictionary where each key is an item name and its associated value is the count of that item. Your task is to increment the count of a specified item by 1. If the item does not exist in the inventory, add it with an initial count of 1. The update operation should have an average time complexity of \(O(1)\).

For example, if the inventory is {"apple": 3, "banana": 2} and you need to update "apple", the resulting inventory would be {"apple": 4, "banana": 2}.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer \(n\) representing the number of items in the inventory.
  • The next \(n\) lines each contain a string (the item name without spaces) and an integer (its count), separated by a space.
  • The final line contains the name of the item to update.

outputFormat

Output the updated inventory as a JSON object (without any extra spaces) on standard output (stdout). The JSON object should map item names to their updated counts.

## sample
2
apple 3
banana 2
apple
{"apple":4,"banana":2}