Submission #428891

#TimeUsernameProblemLanguageResultExecution timeMemory
428891wiwihoIdeal city (IOI12_city)C++14
23 / 100
41 ms3580 KiB
#include <bits/stdc++.h> #define mp make_pair #define F first #define S second #define eb emplace_back #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define uni(a) a.resize(unique(iter(a))); using namespace std; typedef long long ll; using pii = pair<int, int>; const ll MOD = 1000000000; int DistanceSum(int n, int *X, int *Y){ vector<ll> x(n), y(n); for(int i = 0; i < n; i++){ x[i] = X[i]; y[i] = Y[i]; } lsort(x); lsort(y); ll ans = 0; ll sum = 0, cnt = 0; for(int i = 0; i < n; i++){ ans += x[i] * cnt - sum; sum += x[i]; cnt++; } sum = 0; cnt = 0; for(int i = 0; i < n; i++){ ans += y[i] * cnt - sum; sum += y[i]; cnt++; } return ans % MOD; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...