# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964248 | PenguinsAreCute | Wiring (IOI17_wiring) | C++17 | 27 ms | 3932 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;
using ll = long long;
int detNear(int x, vector<int> &r) {
int hi = lower_bound(r.begin(),r.end(),x)-r.begin();
if(hi==r.size()) hi--;
if(hi && x-r[hi-1]<r[hi]-x) return hi-1;
else return hi;
}
long long min_total_length(std::vector<int> r, std::vector<int> b) {
if(r.size()<b.size()) swap(r,b);
int n = r.size(), m = b.size();
ll ans = 0;
for(int i=0;i<n;i++) {
int meow = detNear(r[i],b);
meow=max(min(meow,i),m-n+i);
ans += abs(b[meow] - r[i]);
}
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... |