zoj 2883 Shopaholic

552 단어 c
//2603599 	2011-07-28 16:26:51 	Accepted 	2883 	C++ 	50 	180 	ylwh!
#include <stdio.h>
#include <algorithm>
using namespace std;
bool cmp(int a, int b)
{
	return a>b ? 1: 0;
}
int main()
{
	int t, n, a[20001], i, j, ans;
	scanf("%d", &t);
	while(t--)
	{
		ans = 0;
		j = 2;
		scanf("%d", &n);
		for(i=0; i<n; i++)
			scanf("%d", &a[i]);
		sort(a, a+n, cmp);
		while(j<n)
		{
			ans += a[j];
			j += 3;
		}
		printf("%d
", ans); } return 0; }

좋은 웹페이지 즐겨찾기