이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
const int MOD=1e9;
ll px[MAXN], py[MAXN];
int DistanceSum(int n, int *x, int *y) {
sort(x, x+n); for(int i=0; i<n; i++) px[i]= x[i] + (i==0 ? 0 : px[i-1]);
sort(y, y+n); for(int i=0; i<n; i++) py[i]= y[i] + (i==0 ? 0 : py[i-1]);
ll resp=0;
for(int i=0; i<n; i++) {
ll aa=x[i]; aa*=i; aa-=(i==0 ? 0 : px[i-1]);
ll bb=y[i]; bb*=i; bb-=(i==0 ? 0 : py[i-1]);
aa+=(px[n-1]-px[i]); aa-=((ll)x[i]*(n-i-1));
bb+=(py[n-1]-py[i]); bb-=((ll)y[i]*(n-i-1));
resp+=aa; resp+=bb;
}
return resp/2;
}
| # | 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... |