# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
869397 | teacup | Ideal city (IOI12_city) | C++14 | 26 ms | 1524 KiB |
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;
int DistanceSum(int N, int *X, int *Y){
int minx=(1<<32)-1, miny=(1<<32)-1;
for (int a=0; a<N; a++) {
minx = min(minx, X[a]);
miny = min(miny, Y[a]);
}
sort(X, X+N);
sort(Y, Y+N);
long long bx=0, by=0;
for (int a=0; a<N; a++) {
bx+=(X[a]-X[0]);
by+=(Y[a]-Y[0]);
}
long long ans=(bx+by)%1000000000;
for (int a=1; a<N; a++) {
bx-=(N-a)*(X[a]-X[a-1]);
by-=(N-a)*(Y[a]-Y[a-1]);
ans=(ans+bx+by)%1000000000;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |