#K92122. Coin Changer Operations

    ID: 38128 Type: Default 1000ms 256MiB

Coin Changer Operations

Coin Changer Operations

This problem simulates a coin changer used in a mobile banking application. The coin changer supports three operations:

  • add x: Add a coin with denomination x to the available coins.
  • remove x: Remove the coin with denomination x from the available coins, if it exists.
  • min_coins x: Compute the minimum number of coins required to produce change for an amount x using the available denominations. If it is not possible to form the amount, output \(-1\).

You are to process a series of such operations. For each min_coins operation, output the result on a new line.

inputFormat

The first line contains an integer n, the number of operations. Each of the following n lines contains an operation in one of the following formats: add x, remove x, or min_coins x, where x is a positive integer.

outputFormat

For every min_coins operation, print the result on a separate line. If it is impossible to form the given amount with available coins, output \(-1\).

## sample
7
add 1
add 5
add 10
add 25
min_coins 11
remove 1
min_coins 11
2

-1

</p>