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>
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define uni(a) a.resize(unique(iter(a)));
using namespace std;
typedef long long ll;
using pii = pair<int, int>;
const ll MOD = 1000000000;
int DistanceSum(int n, int *X, int *Y){
vector<ll> x(n), y(n);
for(int i = 0; i < n; i++){
x[i] = X[i];
y[i] = Y[i];
}
lsort(x);
lsort(y);
ll ans = 0;
ll sum = 0, cnt = 0;
for(int i = 0; i < n; i++){
ans += x[i] * cnt - sum;
sum += x[i];
cnt++;
}
sum = 0; cnt = 0;
for(int i = 0; i < n; i++){
ans += y[i] * cnt - sum;
sum += y[i];
cnt++;
}
return ans % MOD;
}
# | 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... |