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 ret = 0 ;
if(r.size() > b.size()){
int p = r.size() - 1 ;
for(int i = b.size() - 1 ; i >= 0 ; i --)
ret += b[i] - r[p--];
int R = r.size() , B = b.size();
for(int i = R - B - 1 ; i >= 0 ; i --)
ret += b[0] - r[i];
}
else {
int p1 = r.size() , p2 = b.size() ;
while(p1 > -1 && p2 > -1){
ret += b[p2] - r[p1];
p2 -- , p1 -- ;
}
long long sum = 0 ;
while(p2 > -1){
sum += b[p2--];
}
ret += (sum - (b.size() - r.size()) * r.back()) ;
}
return ret;
}
# | 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... |