# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208815 | TAISA_ | Wiring (IOI17_wiring) | C++14 | 0 ms | 0 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"
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int n=r.size(),m=b.size();
if(r.back()<b[0]){
reverse(all(b));
ll res=0;
if(n<=m){
for(int i=0;i<n;i++){
res+=b[i]-r[i];
}
for(int i=n;i<m;i++){
res+=b[i]-r.back();
}
}else{
for(int i=0;i<m;i++){
res+=b[i]-r[i];
}
for(int i=m;i<n;i++){
res+=b[0]-r[i];
}
}
return res;
}
return 0;
}