Codey and Team Selection
https://www.hackerrank.com/contests/codenection-2023-preliminary-round-closed-category/challenges/cn-c6
Last updated
https://www.hackerrank.com/contests/codenection-2023-preliminary-round-closed-category/challenges/cn-c6
Last updated
Codey is a coach, and it is assembling a team for a competitive sports league. It is going to select n
players for the team. Each player possesses a skill point represented by . The player selection process consists of n
steps, and in each step:
Let b
to be the sorted array of skill points for unselected players. Choose an integer j
, where , and k is the current total of unselected players, that player joins the team and gains an additional skill point, . In other words, the total team skill increases by .
Codey wants to strategically select players to maximize the overall team skill for the upcoming sports league, while following the constraints of the selection process. Can you help Codey to achieve this?
The first line contains a single integer n
, which represents the number of players.
The second line contains n
integers , each representing the skill points of the -th player.
The third line contains n
integers , each representing the additional skill points gained for selecting the -th player in the array b
.
Output an integer representing the maximum total team skill.
The current team skill is and b = [1, 2, 3]
. We choose j = 1
and the team skill increase by .
The current team skill is and b = [2, 3]
. We choose j = 2
and the team skill increase by .
The current team skill is and b = [2]
. We choose j = 1
and the team skill increase by .
All players are selected, selection ended. The total team skill is .