题目在这里1438
超级水题,排序,隔三求和
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool comp(int i, int j)
{
return i > j;
}
int main()
{
int t, n, pi;
vector<int> prices;
cin >> t;
while (t--)
{
cin >> n;
while (n--)
{
cin >> pi;
prices.push_back(pi);
}
sort(prices.begin(), prices.end(), comp);
int ans = 0;
for (int i = 0; i < prices.size(); i++)
{
if (i % 3 == 2)
ans += prices[i];
}
cout << ans << endl;
prices.clear();
}
system("pause");
return 0;
}