Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

太水了!

Posted by chenxuan123456789 at 2012-08-10 18:10:14 on Problem 2291
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *_a,const void *_b)
{
	int *a=(int*)_a;
	int *b=(int*)_b;
	return *b-*a;
}
int l[1010];
int main()
{
	int cases,i,n,sum;
	scanf("%d",&cases);
	while(cases--)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
		scanf("%d",&l[i]);
		qsort(l,n,sizeof(l[0]),cmp);
		//for(i=0;i<n;i++)
	   // printf("%d\n",l[i]);
        sum=0;
		for(i=0;i<n;i++)
		if(l[i]*(i+1)>sum)
		sum=l[i]*(i+1);
		printf("%d\n",sum);
	}
	return 1;
}



Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator