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

好心人看看~我这样why wa?

Posted by thomas_wu at 2009-03-18 17:41:12 on Problem 1723
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
    int x[10000];
    int y[10000];
    
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];
    sort(x,x+n);
    sort(y,y+n);
    
    int p=n/2;
    int yy=y[p];
    int xx=x[p];
    
    long long sum=0;
    
    for(int i=0;i<n;i++)sum+=abs(yy-y[i]);
    for(int i=0;i<n;i++)sum+=abs(xx-(p-i)-x[i]);
    cout<<sum<<endl;
    cin>>n;
}

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