Submission #104429

# Submission time Handle Problem Language Result Execution time Memory
104429 2019-04-06T18:45:18 Z wilwxk Ideal city (IOI12_city) C++11
23 / 100
43 ms 3576 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]);
		resp+=aa; resp+=bb;
		resp%=MOD;
	}

	return resp;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 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 Correct 9 ms 868 KB Output is correct
2 Correct 10 ms 896 KB Output is correct
3 Correct 16 ms 1920 KB Output is correct
4 Correct 20 ms 1920 KB Output is correct
5 Correct 30 ms 3448 KB Output is correct
6 Correct 30 ms 3468 KB Output is correct
7 Correct 31 ms 3576 KB Output is correct
8 Correct 33 ms 3464 KB Output is correct
9 Correct 43 ms 3448 KB Output is correct
10 Correct 36 ms 3472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -