# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208289 | a_player | Wiring (IOI17_wiring) | C++14 | 5 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
typedef long long ll;
bitset<MAXN> vb;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
ll ans=0;
for(int x:r){
ll mini=LLONG_MAX;
int p=upper_bound(b.begin(),b.end(),x)-b.begin();
if(p!=0)mini=(ll)(x-b[p-1]),vb[p-1]=1;
if(p!=b.size()&&(ll)(b[p]-x)<mini)mini=(ll)(b[p]-x),vb[p]=1;
ans+=mini;
}
for(int i=0;i<b.size();i++){
if(vb[i])continue;
ll mini=LLONG_MAX;
int p=upper_bound(r.begin(),r.end(),b[i])-r.begin();
if(p!=0)mini=(ll)(b[i]-r[p-1]);
if(p!=r.size()&&(ll)(r[p]-b[i])<mini)mini=(ll)(r[p]-b[i]);
ans+=mini;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |