Submission #150910

#TimeUsernameProblemLanguageResultExecution timeMemory
150910youssefbou62Ideal city (IOI12_city)C++14
23 / 100
39 ms3704 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...