Choose the perfect team

Revision en1, by myaw, 2020-11-10 22:34:52

Hi cf,

I'm trying to solve this problem:

You have a budget B and you want to form a team of 11 players such as it has:

  • 1 goalkeeper
  • At least 3 defenders and at most 5.
  • At least 3 midfielders and at most 5.
  • At least 1 attackers and at most 3.

There's a list of players (max 50) to choose from, with each player has a:

  • type: goalkeeper, defender, midfilder or attacker
  • cost: price of the player
  • points: represent how good the player is

What is the maximum of total points that we can get from a team that fulfill the conditions without exceeding the budget B

it is guaranteed that the maximum number of players per type in the input doesn't ecxeed 15.

Example of input:

Defender 22.5 7
Attacker 40 9

All I can think of is recurssive dp with bitmask dp(chossenGkmask, chossenDefmask, chosseMidmask, chossenAttmask, totalCoast)

Is there a better approach ?

Tags dp, #greedy

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English myaw 2020-11-11 02:40:57 17 Tiny change: ' <= 10\n\n Each' -> ' <= 10\n\nbudget <= 100\n\n Each'
en3 English myaw 2020-11-11 02:36:29 43
en2 English myaw 2020-11-11 02:22:31 135 Tiny change: 's) <= 50\n Each ty' -> 's) <= 50\n\n Each ty'
en1 English myaw 2020-11-10 22:34:52 960 Initial revision (published)