# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
805339 |
2023-08-03T15:27:19 Z |
aymanrs |
Ideal city (IOI12_city) |
C++14 |
|
10 ms |
1152 KB |
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9;
int DistanceSum(int N, int *X, int *Y){
vector<pair<int, int>> x, y;
for(int i = 0;i < N;i++){
x.emplace_back(X[i], i);
y.emplace_back(Y[i], i);
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
long long ans = 0;
for(int i = 0;i < N;i++){
long long p = lower_bound(x.begin(), x.end(), make_pair(X[i], i))-x.begin();
ans += p*X[i]%MOD;
ans -= (N-p-1)*X[i]%MOD;
ans %= MOD;
p = lower_bound(y.begin(), x.end(), make_pair(Y[i], i))-x.begin();
ans += p*Y[i]%MOD;
ans -= (N-p-1)*Y[i]%MOD;
ans %= MOD;
}
return (ans+MOD)%MOD;
}
# |
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 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |