Submission #1213332

#TimeUsernameProblemLanguageResultExecution timeMemory
1213332LIAIdeal city (IOI12_city)C++17
0 / 100
1095 ms2020 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef tuple<ll, ll, ll> plll; typedef vector<plll> vplll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<pll> vpll; typedef vector<vector<pll>> vvpll; typedef vector<vector<ll>> vvll; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; #define loop(i, s, e) for (ll i = (s); i < (e); ++i) #define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i) #define all(a) a.begin(), a.end() const ll inf = 1e9; ll ans = 0; ll n; int DistanceSum(int N, int *x, int *y) { n=N; multiset<ll> xi, yi; loopr(i,n,0) { ll in = i-n+2; ll bigger= distance(xi.lower_bound(x[i]), xi.end()); ll smaller = in-bigger; ans = (ans -bigger*x[i] + smaller*x[i]); bigger= distance(yi.lower_bound(y[i]), yi.end()); smaller = in-bigger; ans = (ans -bigger*y[i] + smaller*y[i]); xi.insert(x[i]); yi.insert(y[i]); } loop(i,n,0) { ll in = i+1; ll bigger= distance(xi.lower_bound(x[i]), xi.end()); ll smaller = in-bigger; ans = (ans -bigger*x[i] + smaller*x[i]); bigger= distance(yi.lower_bound(y[i]), yi.end()); smaller = in-bigger; ans = (ans -bigger*y[i] + smaller*y[i]); xi.insert(x[i]); yi.insert(y[i]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...