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

水题专杀户的第25题..大神莫笑..

Posted by wmw_ac at 2012-08-15 13:43:41 on Problem 2291
#include <stdio.h>
#include <stdlib.h>

int cmp ( const void *a , const void *b )
{
	return *(int *)b - *(int *)a;
}

int main()
{
	int a[1002],n,m,j,t,z;
	scanf("%d",&n);
	while(n--){
		scanf("%d",&m);
		for (j=0;j<m;j++){
			scanf("%d",&a[j]);
		}
		qsort(a,m,sizeof(a[0]),cmp);
		z = 0;
		for (j=1;j<=m;j++){
			t = a[j-1]*j;
			if (z<t){
				z = t;
			}
		}
		printf("%d\n",z);
	}
	return 0;
}

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