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;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
long long t=0;
auto tr=r,tb=b;
reverse(r.begin(),r.end());reverse(b.begin(),b.end());
while(!r.empty()&&!b.empty()){
int rr=r.back(),bb=b.back();
r.pop_back();b.pop_back();
t+=abs(rr-bb);
}
while(!r.empty()){
int rr=r.back();t+=abs(rr-tb[0]);r.pop_back();
}
while(!b.empty()){
int bb=b.back();t+=abs(bb-tr.back());b.pop_back();
}
return t;
}
# | 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... |