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 lhzlucky at 2006-12-24 22:17:11 on Problem 2291
#include<stdio.h>
#include<iostream>
using namespace std;
int a[10001];
int cmp(const void*a,const void*b)
{
	int t=*(int*)a<*(int*)b?1:0;
	return t;
}
void main()
{
	int t,n,i,j,s;
    cin>>t;
	while(t--)
	{
		cin>>n;
		s=-1;
		for(i=0;i<n;i++)
			cin>>a[i];
		qsort(a,n,sizeof(int),cmp);
		for(i=0;i<n;i++)
			if(s<(i+1)*a[i])s=(i+1)*a[i];
        cout<<s<<endl;
	}
}

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