Sunday, July 17, 2016

UVA 11369 Solution

Unknown
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
    int t,n,p[20005],dis;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d",&n);
        for (int i=0;i<n;i++)
            scanf("%d",&p[i]);
        sort(p,p+n);
        int i=n-1;
        dis=0;
        while (i>1)
        {
            dis+=p[i-2];
            i-=3;
        }
        printf("%d\n",dis);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,