It's the 8th day. M League I am writing while looking at it.
#8 Problem
** Thoughts ** Actually, I skipped this problem because it seemed unsolvable when I saw it at a glance. This time, I took plenty of time to think about it, so I solved it. The second strongest person in the team will be the strength of the team, so we have to think about how to keep the second strongest person.
Sort 3N members in descending order and call it A. If N people from behind A are added to the team one by one, it will always be the minimum value in the team. Putting the remaining two A [: 2 * N] into the same team will maximize the strength of each team.
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
a = a[:2*n]
ans = 0
for i in range(1,2*n,2):
ans += a[i]
print(ans)
I hope the next AGC can also solve about A. It has nothing to do with competition pros, but let's take a look at the M League because it is interesting.
Recommended Posts