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
const int M = 1e9;
int32_t DistanceSum(int32_t n, int32_t X[], int32_t Y[]) {
int ans = 0, sum = 0;
sort(X, X+n);
for (int i=0;i<n;i++) ans += i * X[i] - sum, ans %= M, sum += X[i];
sum = 0;
sort(Y, Y+n);
for (int i=0;i<n;i++) ans += i * Y[i] - sum, ans %= M, sum += Y[i];
return ans;
}
# | 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... |