Souvenirs
Time limit1sMemory limit256 MB
Buy souvenirs from merchants in order with gold and silver coins and choose how to pay each price to maximize the number bought.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Greedy, Simulation
- Solved
- No attempts yet
Problem
Buy souvenirs from merchants in order using gold coins (worth silver) and silver coins. Merchants round change in silver packages as greedy, honest, or generous. Generous merchants require exact silver payment when possible; otherwise pay one gold coin. Other merchants accept exact silver or one gold coin. Maximize purchases.
Input
, , , then lines with merchant type, package size , and price .
Output
Maximum number of souvenirs you can buy.