This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int xar[500005];
int yar[500005];
signed main(){
cin>>n;
for(int i=1;i<=n*2;i++){
cin>>xar[i]>>yar[i];
}
sort(xar+1,xar+n+n+1);
sort(yar+1,yar+n+n+1);
int ans=0;
for(int i=1;i<=n+n;i++){
int pl=(i+1)/2;
ans+=abs(pl-xar[i]);
}
for(int i=1;i<=n;i++){
ans+=abs(yar[i]-1)+abs(yar[i+n]-2);
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |