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 |
Re:有用C写过的没??怎么写不超时啊???我写的超时,郁闷,牛子指点下In Reply To:有用C写过的没??怎么写不超时啊???我写的超时,郁闷,牛子指点下 Posted by:bootshl at 2008-07-26 13:23:25 > #include <stdio.h> > #include <stdlib.h> > int MyCompare(const void* e1, const void* e2); > > int main() > { > int n1, n2, n, count_max, i, nmax; > long a, max[50]; > double sum; > while (scanf("%d%d%d", &n1, &n2, &n) == 3 && n1) { > sum = 0; > count_max = 0; > for (i = 0; i < n; i++) { > scanf("%ld", &a); > if (i < n1+n2) { > max[count_max++] = a; > sum += a; > continue; > } > qsort(max, n1+n2, sizeof(long),MyCompare); > if (a > max[n1+n2-n1]) > max[n1+n2-n1] = a; > if (a < max[n2-1]) > max[n2-1] = a; > sum += a; > } > > for (i = 0; i < n1+n2; i++) > sum -= max[i]; > printf("%.6lf\n", sum/(n-n1-n2)); > } > return 0; > } > > > int MyCompare(const void* e1, const void* e2) > { > return *((long*)e1) - *((long*)e2); > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator