1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <algorithm> #define ll long long using namespace std; vector<int> vb; bool cmp(int a,int b) { return a>b; } int main() { int t,n,a; cin>>t; ll sum; while(t--) { cin>>n; vb.clear(); for(int i=0;i<n;i++) { cin>>a; vb.push_back(a); } sort(vb.begin(),vb.end(),cmp); if(n<3) printf("0\n"); else { sum=0; for(int i=2;i<n;i+=3) sum+=vb[i]; } printf("%lld\n",sum); } return 0; } |