Player-based Team Distribution
InterviewTime limit1sMemory limit1024 MB
Partition N players into teams; a player with value a_i in a team of size s scores s*a_i. Maximize the total score.
- Level
Medium4 of 10
- Topics
- Greedy, Sorting, Math, Implementation
- Solved
- No attempts yet
Problem
We want to split players into one or more teams and play a game. Each player must belong to exactly one team. The -th player gains a score equal to the number of players on the same team multiplied by .
Find the maximum possible sum of all players' scores over all ways to split the players into teams.
Input
The first line contains . ()
The second line contains integers. The -th number is . ()
Output
Print on the first line the maximum sum of all players' scores over all ways to split the players into teams.