Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
c++提交,怎么能超时呢,WTF#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator