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

求教,一直显示wrong answer,用一组测试数据结果没错

Posted by mmmm123 at 2016-03-24 15:45:09 on Problem 1723
#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:
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