Problem Link : https://www.codechef.com/LICO2020/problems/DCANDY

Distribution is such that from the three picked candies, GOVI gets the candy with the minimum sweetness. Now in order to get the maximum sweetness, the picking of candies should be done in such a way that she picks candies with maximum available sweetness.

Here is the code:

```
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
bool cmp(int a, int b)
{
return a > b;
}
int main(void)
{
ll test;
cin >> test;
while (test--)
{
ll n;
cin >> n;
ll arr[n];
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
sort(arr, arr + n, cmp);
ll sweetness = 0;
for (int i = 0; i < n; i++)
{
if ((i + 1) % 3 == 0)
{
sweetness += arr[i];
}
}
cout << sweetness << endl;
}
return 0;
}
```