# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208287 | 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;
bitset<MAXN> vb;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int ans=0;
for(int x:r){
int mini=INT_MAX;
int p=upper_bound(b.begin(),b.end(),x)-b.begin();
if(p!=0)mini=x-b[p-1],vb[p-1]=1;
if(p!=b.size()&&b[p]-x<mini)mini=b[p]-x,vb[p]=1;
ans+=mini;
}
for(int i=0;i<b.size();i++){
if(vb[i])continue;
int mini=INT_MAX;
int p=upper_bound(r.begin(),r.end(),b[i])-r.begin();
if(p!=0)mini=b[i]-r[p-1];
if(p!=r.size()&&r[p]-b[i]<mini)mini=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... |