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:求教,一直显示wrong answer,用一组测试数据结果没错In Reply To:求教,一直显示wrong answer,用一组测试数据结果没错 Posted by:mmmm123 at 2016-03-24 15:45:09 > #include<stdio.h> > #include<math.h> > #include<stdlib.h> > void sort(int a[],int low,int high) > { > > int i = low; > int j = high; > int temp = a[i]; > > if( low < high) > { > while(i < j) > { > while((a[j] >= temp) && (i < j)) > { > j--; > } > a[i] = a[j]; > while((a[i] <= temp) && (i < j)) > { > i++; > } > a[j]= a[i]; > } > a[i] = temp; > sort(a,low,i-1); > sort(a,j+1,high); > } > } > int main() > { > int t,b,c,x[10000],y[10000],x1[10000],i,j,sum=0; > scanf("%d",&t); > for(i=1;i<=t;i++) > { > scanf("%d%d",&b,&c); > x[i]=b; > y[i]=c; > } > sort(x,1,t); > sort(y,1,t); > for(i=1;i<=t;i++) > x1[i]=x[i]-i+1; > sort(x1,1,t); > for(i=1;i<=t;i++) > { > sum+=abs(x1[i]-x1[t/2]); > sum+=abs(y[i]-y[t/2]); > } > printf("%d",sum); > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator