# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
288796 | Leonardo_Paes | Wiring (IOI17_wiring) | C++17 | 41 ms | 2060 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 <bits/stdc++.h>
#include <wiring.h>
using namespace std;
const long long inf = 1e18+10;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
long long ans = 0LL;
if(r.size() > b.size()) swap(r, b);
for(int i=0; i<r.size(); i++) ans += abs(r[i] - b[i]);
for(int i=r.size(); i<b.size(); i++){
long long d = inf;
auto it = lower_bound(r.begin(), r.end(), b[i]);
if(it != r.end()) d = abs(b[i] - *it);
if(it != r.begin()){
it--;
d = min(d, 1LL*abs(b[i] - *it));
}
if(d != inf) ans += d;
}
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... |