atcoder#AGC012A. [AGC012A] AtCoder Group Contest
[AGC012A] AtCoder Group Contest
Score : points
Problem Statement
There are participants in AtCoder Group Contest. The strength of the -th participant is represented by an integer . They will form teams, each consisting of three participants. No participant may belong to multiple teams.
The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength , , has a strength , and a team of three participants of strength , , has a strength .
Find the maximum possible sum of the strengths of teams.
Constraints
- are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2
5 2 8 5 1 5
10
The following is one formation of teams that maximizes the sum of the strengths of teams:
- Team : consists of the first, fourth and fifth participants.
- Team : consists of the second, third and sixth participants.
10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
10000000000
The sum of the strengths can be quite large.