Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help me code in java programming langauge only pls .it has to be right and produce the exact output as in the picture. Anthony and

image text in transcribed

image text in transcribed

image text in transcribed

help me code in java programming langauge only pls .it has to be right and produce the exact output as in the picture.

Anthony and Cora are playing Dominion, their favorite card game. In Dominion, there are T different card types, and each player has a set of cards (known as a deck). A deck D is said to have C combos if C is the largest integer such that for C different card types in the game, D contains at least two cards of that type. Anthony currently has N cards and he wants to trade cards with Cora such that he'll have a deck with exactly K combos. For each card type i(1iT), Anthony can choose to perform at most one transaction. There are two types of transaction: 1. Buy up to two cards of ith type from Cora at ai coins each 2. Sell all his cards of ith type for bi coins each Anthony wants to maximize his profit while obtaining a complete deck. Anthony is willing to spend coins in order to obtain a complete deck if necessary, but of course he wants to minimize his spending in that case. Note that he doesn't care about keeping the rest of his cards which don't contribute to the complete deck. Anthony has hired you to help him calculate how much money he can make if he chooses the optimal strategy for obtaining enough combos. If he has to spend money, output a negative number. Input The first line of the input contains three integers N,T, and K, 1KT100000,1N2T The next line is a list of N integers representing the cards in Anthony's deck. Each integer on this line is between 1 and T inclusive. It is guaranteed no integers appear more than twice. Finally, each of the next T lines of the input contains two integers each. The ith line contains ai and bi,1ai,bi109, corresponding to the price of buying and selling a card of type i. Output Output a single integer denoting Anthony's profit assuming he trades optimally. Explanation of Sample Input In the first example, Anthony should sell two of card 1 and buy one of card 2 and one of card 3 for a net profit of 10 coins. If he chooses to sell one of card 3 and buy one of card 2, then he'll end up spending 20 coins. Sample Input 1 Sample Output 1 432 10 1321 150 5020 4030 Sample Input 2 Sample Output 2 432 20 1321 120 5020 4030

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago