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

c++提交,怎么能超时呢,WTF

Posted by 1531474017 at 2012-04-29 10:40:50 on Problem 2623
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int cmp(const void *a,const void *b)
{
	return *(unsigned long *)a>*(unsigned long *)b?1:-1;
}
int main()
{
	unsigned long n,i,a[250002];
	scanf("%lu",&n);
	i=0;
	for(;i<n;i++)
	{
		scanf("%lu",&a[i]);
	}
	qsort(a,n,sizeof(unsigned long),cmp);
	double res=(n%2==0)?(a[n/2]/2.0+a[n/2-1]/2.0):a[n/2];
	printf("%.1lf",res);
	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