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 |
用 nth_element 做不是更好吗? 怎末wa 了 溢出也解决了啊#include<stdio.h> #include<algorithm> using namespace std; int a[250000]; int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); nth_element(a,a+n/2,a+n); if(n&1) printf("%d.0\n",a[n/2]); else { nth_element(a,a+n/2,a+n/2); double ans = (double)1.0*(a[n/2-1]+a[n/2])/2; printf("%.1f\n",ans); } // system("pause"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator