Submission #150910

# Submission time Handle Problem Language Result Execution time Memory
150910 2019-09-01T10:43:30 Z youssefbou62 Ideal city (IOI12_city) C++14
23 / 100
39 ms 3704 KB
#include  <bits/stdc++.h>
// #include "city.h"
#pragma  GCC optimize ("O3")
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }

ll ans ;
int root ; 
const int N = 2e5+5; 
const ll mod = 1e9 ; 
ll x[N],y[N]; 


int DistanceSum(int N, int *X, int *Y){
	ll sumX = 0 , sumY=0; 
	for(int i = 0 ; i < N ; i++ ){
		x[i] = X[i] ; 
		y[i] = Y[i] ; 
		sumX += x[i] ; 
		sumY += y[i] ; 
	}
	ll ans = 0 ;
	sort(x,x+N) ; 
	sort(y,y+N) ; 
	int n = N ; 
	// reverse(x,x+N); 
	// reverse(y,y+N); 
	for(int i = 0 ; i < n ; i++ ){
		ans += sumX - x[i]*1LL*(n-i) ; 
		ans %= mod ; 
		sumX -= x[i] ; 
	}
	for(int i = 0 ; i < n ; i++ ){
		ans += sumY - y[i]*1LL*(n-i) ; 
		ans %= mod ; 
		sumY -= y[i] ; 
	}
	return ans; 
}
// int main(){
// 	int n ; cin >> n ; for(int i = 0 ; i < n ; i++ )cin >> x[i]>>y[i] ; cout << DistanceSum(n,x,y)<<endl; 
// }
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1016 KB Output is correct
2 Correct 8 ms 1016 KB Output is correct
3 Correct 18 ms 2004 KB Output is correct
4 Correct 18 ms 1940 KB Output is correct
5 Correct 35 ms 3452 KB Output is correct
6 Correct 35 ms 3448 KB Output is correct
7 Correct 39 ms 3704 KB Output is correct
8 Correct 35 ms 3496 KB Output is correct
9 Correct 35 ms 3408 KB Output is correct
10 Correct 35 ms 3540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -