# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109525 |
2019-05-06T19:47:02 Z |
pamaj |
Ideal city (IOI12_city) |
C++14 |
|
43 ms |
5224 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9;
typedef long long ll;
ll prefx[maxn], prefy[maxn];
ll get_sum(int i, int j)
{
ll s = 0;
s = prefx[j] + prefy[j] - prefx[i - 1] - prefy[i - 1];
return s;
}
int DistanceSum(int N, int *X, int *Y)
{
ll x[maxn];
ll y[maxn];
for(int i = 0; i < N; i++)
{
x[i] = X[i];
y[i] = Y[i];
}
sort(x, x + N);
sort(y, y + N);
for(int i = 0; i < N; i++)
{
if(i == 0) prefx[i] = x[i], prefy[i] = y[i];
else prefx[i] = x[i] + prefx[i - 1], prefy[i] = y[i] + prefy[i - 1];
}
ll sum = 0;
for(int i = 0; i < N - 1; i++)
{
sum += get_sum(i + 1, N - 1) - (ll)(N - i - 1)*(x[i] + y[i])%mod;
sum %= mod;
}
return sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1152 KB |
Output is correct |
2 |
Correct |
8 ms |
1280 KB |
Output is correct |
3 |
Correct |
19 ms |
2688 KB |
Output is correct |
4 |
Correct |
19 ms |
2696 KB |
Output is correct |
5 |
Correct |
43 ms |
5120 KB |
Output is correct |
6 |
Correct |
34 ms |
4984 KB |
Output is correct |
7 |
Correct |
36 ms |
5224 KB |
Output is correct |
8 |
Correct |
33 ms |
5112 KB |
Output is correct |
9 |
Correct |
36 ms |
4984 KB |
Output is correct |
10 |
Correct |
37 ms |
5000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |