Submission #251551

# Submission time Handle Problem Language Result Execution time Memory
251551 2020-07-21T19:16:20 Z kostia244 Ideal city (IOI12_city) C++17
23 / 100
29 ms 2808 KB
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<18;
int cx[maxn], cy[maxn];
int DistanceSum(int n, int *X, int *Y) {
	ll sum = 0;
	int minx = 1<<30, miny = 1<<30;
	for(int i = 0; i < n; i++) {
		minx = min(minx, X[i]),
		miny = min(miny, Y[i]);
	}
	for(int i = 0; i < n; i++) {
		X[i] -= minx, Y[i] -= miny;
		cx[X[i]]++, cy[Y[i]]++;
	}
	for(int i = 1; i < n; i++) cx[i] += cx[i-1];
	for(int i = 1; i < n; i++) cy[i] += cy[i-1];
	for(int i = 0; i < n; i++) {
		if(X[i]) sum += (cx[X[i]-1])*1ll*X[i];
		sum -= (n-cx[X[i]])*1ll*X[i];
		if(Y[i]) sum += (cy[Y[i]-1])*1ll*Y[i];
		sum -= (n-cy[Y[i]])*1ll*Y[i];
	}
	return sum%1000000000;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 640 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 13 ms 1536 KB Output is correct
4 Correct 12 ms 1536 KB Output is correct
5 Correct 26 ms 2688 KB Output is correct
6 Correct 25 ms 2688 KB Output is correct
7 Correct 27 ms 2808 KB Output is correct
8 Correct 29 ms 2680 KB Output is correct
9 Correct 25 ms 2680 KB Output is correct
10 Correct 25 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -