You’ve decided to get rid of your Trading Card Game (TCG) collection. The possible financialactivities are as follows: - You can sell individual cards to Bearimy’s Card Emporium. - You can buy individ
You’ve decided to get rid of your Trading Card Game (TCG) collection. The possible financial activities are as follows: - You can sell individual cards to Bearimy’s Card Emporium. - You can buy individual cards from Bearimy’s Card Emporium. - Card price is the same regardless of the transaction (buy or sell) with the Emporium. - You can sell a set of cards (called a collection) to your friend Jeremy. Jeremy enjoys showing off different collection sets, so Jeremy will buy multiple sets but only one of each set. You have to, of course, have the cards in a set to be able to sell such set to Jeremy. - If a card is needed in different collection sets, you only need one copy of that card (and not multiple copies of that card) to form all those sets to sell to Jeremy; you need the other cards in the sets as well. For example, if cards {1,2} is a set, cards {2,3} is a set, and cards {1,3,4} is a set, to sell these three sets to Jeremy, you only need one of each card 1, 2, 3, and 4. - Jeremy only buys collection sets and not individual cards. - A collection set is not necessarily more/less expensive than the sum of its component cards. Given a list of cards, including their card shop cost and whether you own them, and a list of collection sets and the value Jeremy will pay for those sets, determine the maximum amount of money you can earn. This is done by buying from (and/or selling to) the card shop and selling the sets to Jeremy. Note that you choose what to buy from (and/or sell to) the card shop and what to sell to Jeremy. Your earning will be: (cards sold to the shop) + (sets sold to Jeremy) – (cards bought from the shop)