#define MOD 1000000000
#define INF 2147483646
#define min2(x,y) (x<y?x:y)
int n;
int cnt_X[100001], cnt_Y[100001];
int DistanceSum(int _n, int *X, int *Y) {
n = _n;
int x_min=INF, y_min=INF;
long long out = 0, t1, t2, t3;
for (int i = 0; i < n; i++) x_min = min2(x_min, X[i]), y_min = min2(y_min, Y[i]);
for (int i = 0; i < n; i++) cnt_X[X[i] - x_min]++, cnt_Y[Y[i] - y_min]++;
for (int i = 0; i<n; i++)
for (int j = i + 1; j < n; j++) {
t1 = cnt_X[i], t2 = cnt_X[j], t3 = j - i;
out += (t1*t2*t3) % MOD, out %= MOD;
}
for (int i = 0; i<n; i++)
for (int j = i + 1; j < n; j++) {
t1 = cnt_Y[i], t2 = cnt_Y[j], t3 = j - i;
out += (t1*t2*t3) % MOD, out %= MOD;
}
return (int)out;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
2104 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
2104 KB |
Execution timed out |
2 |
Halted |
0 ms |
0 KB |
- |