#P2663. 越越的组队
越越的组队
Description
The class is organizing a comprehensive ability competition. There are students in the class, and they will be divided into two teams to compete against each other.
The teacher gave Yueyue (pinyin) a list of the comprehensive ability test scores for the whole class and asked him to select exactly half of the students, such that the sum of their test scores is as large as possible without exceeding half of the class's total score. This makes the two teams as balanced as possible. Yueyue, smiling, came to you; please help him write a program.
Input Format
The first line contains an integer representing the number of students .
From line to line , each line contains one integer. The integer on line , , represents the score of the -th student.
Output Format
Output one integer on a single line representing the answer.
8
77
77
56
77
84
77
56
46
273
Hint
Explanation for Sample 1
The class total score is , and half of the total is . Choosing students with scores gives a sum of , which is the maximum that does not exceed .
Constraints
For all test points, it is guaranteed that , , and is even.
Translated by ChatGPT 5
京公网安备 11011102002149号