T1:玩具
代码:
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6+10;
int n;
int a[N];
int main()
{
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a, a + n, greater<int>());
long long sum = 0;
for(int i = 0; i < n; i += 2)
{
sum += a[i];
}
cout << sum << endl;
return 0;
}
运行: