sicily 1428之水题一道

来源:互联网 发布:js跨域解决方案c# 编辑:程序博客网 时间:2024/05/22 16:40

题目在这里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;}


0 0