#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9;
int DistanceSum(int N, int *X, int *Y) {
ll ans = 0, tot = 0;
sort(X,X+N), sort(Y,Y+N);
for(ll i = 0; i < N; i++){
ans+=(1ll*X[i]*i-tot+MOD)%MOD;
tot+=X[i], tot%=MOD; ans%=MOD;
}
tot = 0;
for(ll i = 0; i < N; i++){
ans+=(1ll*Y[i]*i-tot+MOD)%MOD;
tot+=Y[i], tot%=MOD; ans%=MOD;
}
return (int)ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
468 KB |
Output is correct |
2 |
Correct |
4 ms |
512 KB |
Output is correct |
3 |
Correct |
11 ms |
676 KB |
Output is correct |
4 |
Correct |
16 ms |
660 KB |
Output is correct |
5 |
Correct |
21 ms |
1108 KB |
Output is correct |
6 |
Correct |
22 ms |
1096 KB |
Output is correct |
7 |
Correct |
26 ms |
1108 KB |
Output is correct |
8 |
Correct |
21 ms |
1156 KB |
Output is correct |
9 |
Correct |
21 ms |
1052 KB |
Output is correct |
10 |
Correct |
21 ms |
1160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |