# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
104428 |
2019-04-06T18:43:32 Z |
wilwxk |
Ideal city (IOI12_city) |
C++11 |
|
10 ms |
1024 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
const int MOD=1e9;
ll px[MAXN], py[MAXN];
int DistanceSum(int n, int *x, int *y) {
sort(x, x+n); for(int i=0; i<n; i++) px[i]= x[i] + (i==0 ? 0 : px[i-1]);
sort(y, y+n); for(int i=0; i<n; i++) py[i]= y[i] + (i==0 ? 0 : py[i-1]);
ll resp=0;
for(int i=0; i<n; i++) {
ll aa=x[i]; aa*=i; aa-=(i==0 ? 0 : px[i-1]);
ll bb=y[i]; bb*=i; bb-=(i==0 ? 0 : py[i-1]);
aa+=(px[n-1]-px[i]); aa-=((ll)x[i]*(n-i-1));
bb+=(py[n-1]-py[i]); bb-=((ll)y[i]*(n-i-1));
resp+=aa; resp+=bb;
}
return resp/2;
}
# |
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 |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |