sicily 1438

#include <iostream> #include <algorithm> using namespace std; int data[20000]; bool cmp(int x, int y) { return x > y; } int main() { int T; cin >> T; while(T--) { int n; cin >> n; for(int i = 0; i < n; i++) cin >> data[i]; sort(data, data + n, cmp); int discount = 0; for(int i = 2; i < n; i += 3) discount += data[i]; cout << discount << endl; } return 0; } 

你可能感兴趣的:(sicily 1438)