# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
805342 |
2023-08-03T15:29:18 Z |
aymanrs |
Ideal city (IOI12_city) |
C++14 |
|
58 ms |
3808 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(), y.end(), make_pair(Y[i], i))-y.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 |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1024 KB |
Output is correct |
2 |
Correct |
10 ms |
1152 KB |
Output is correct |
3 |
Correct |
27 ms |
2128 KB |
Output is correct |
4 |
Correct |
27 ms |
2088 KB |
Output is correct |
5 |
Correct |
55 ms |
3640 KB |
Output is correct |
6 |
Correct |
55 ms |
3528 KB |
Output is correct |
7 |
Correct |
57 ms |
3808 KB |
Output is correct |
8 |
Correct |
55 ms |
3636 KB |
Output is correct |
9 |
Correct |
58 ms |
3632 KB |
Output is correct |
10 |
Correct |
50 ms |
3628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |