| ||||||||||
| 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:好心人看看~我这样why wa?In Reply To:好心人看看~我这样why wa? Posted by:thomas_wu at 2009-03-18 17:41:12 > #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator