atcoder#AGC001A. [AGC001A] BBQ Easy
[AGC001A] BBQ Easy
Score : points
Problem Statement
Snuke is having a barbeque party.
At the party, he will make servings of Skewer Meal.
Example of a serving of Skewer Meal
He has a stock of skewers, all of which will be used in Skewer Meal. The length of the -th skewer is . Also, he has an infinite supply of ingredients.
To make a serving of Skewer Meal, he picks skewers and threads ingredients onto those skewers. Let the length of the shorter skewer be , then the serving can hold the maximum of ingredients.
What is the maximum total number of ingredients that his servings of Skewer Meal can hold, if he uses the skewers optimally?
Constraints
- For each , is an integer.
Input
The input is given from Standard Input in the following format:
Output
Print the maximum total number of ingredients that Snuke's servings of Skewer Meal can hold.
2
1 3 1 2
3
If he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold and ingredients, for the total of .
5
100 1 2 3 14 15 58 58 58 29
135