Submission #202718

#TimeUsernameProblemLanguageResultExecution timeMemory
202718ZloyHRWiring (IOI17_wiring)C++17
0 / 100
5 ms376 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef pair<pll,ll> plll; typedef pair<pll,pll> ppll; typedef long double ld; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fst first #define snd second #define ins insert #define pb push_back template< typename T,typename V>ostream &operator<< (ostream &out,const pair<T,V> x){ out << "{" << x.fst << " : " << x.snd << "}"; return out;}template< typename T>ostream &operator<< (ostream &out,const set<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T>ostream &operator<< (ostream &out,const multiset<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T,typename V>ostream &operator<< (ostream &out,const map<T,V> x){ for(auto &it : x){ out << "[" << it.fst << "]" << " = " << it.snd << "\n"; } return out;}template< typename T>ostream &operator<< (ostream &out,const vector<T> x){ for(int i = 0;i < x.size() - 1; ++i){ out << x[i] << " "; } out << x.back(); return out;}template< typename T>ostream &operator<< (ostream &out,const vector<vector<T> > x){ for(int i = 0;i < x.size() - 1; ++i){ out << "[" << i << "]" << " = {" << x[i] << "}\n"; } out << "[" << x.size() - 1 << "]" << " = {" << x.back() << "}\n"; return out;} const ll N = 1e6 + 5; const ll MOD = 1e9 + 7; const ll INF = 1e17; vector<pll> a; long long min_total_length(std::vector<int> r, std::vector<int> b) { ll n = r.size(),m = b.size(); ll mxa = 0; for(ll i = 0;i < n; ++i){ ll x; x = r[i]; mxa = max(mxa,x); a.pb({x,0}); } ll mnb = INF; for(ll i = 0;i < m; ++i){ ll x; x = b[i]; mnb = min(mnb,x); a.pb({x,1}); } sort(all(a)); vector<ll> pos; ll ans = 0; int tp = -1; for(auto &it : a){ if(pos.empty() || it.snd == tp){ tp = it.snd; pos.pb(it.fst); }else{ ans += it.fst - pos.back(); pos.pop_back(); } } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...