이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<18;
int cx[maxn], cy[maxn];
int DistanceSum(int n, int *X, int *Y) {
ll sum = 0;
int minx = 1<<30, miny = 1<<30;
for(int i = 0; i < n; i++) {
minx = min(minx, X[i]),
miny = min(miny, Y[i]);
}
for(int i = 0; i < n; i++) {
X[i] -= minx, Y[i] -= miny;
cx[X[i]]++, cy[Y[i]]++;
}
for(int i = 1; i < n; i++) cx[i] += cx[i-1];
for(int i = 1; i < n; i++) cy[i] += cy[i-1];
for(int i = 0; i < n; i++) {
if(i) sum += (cx[i-1])*1ll*X[i];
sum -= (n-cx[i])*1ll*X[i];
if(i) sum += (cy[i-1])*1ll*Y[i];
sum -= (n-cy[i])*1ll*Y[i];
}
return sum%1000000000;
}
# | 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... |