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>
#define sz(x) (int)x.size()
#define ll long long
using namespace std;
const int MAXN = 205 ;
bool taken[MAXN] ;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int R = sz(r) , B = sz(b) ;
ll ans = 0 ;
for(int i = 0 , j = 0 ; j < B && i < R ; i++ , j++ ){
ans += 1LL*abs(r[i]-b[i]) ;
}
if(R>B){
for(int i = R-1 , c = 0 ; c < R-B ; c++ , i-- ){
ans += 1LL*abs(r[i]-b[B-1]);
}
}else{
for(int i = B-1 , c = 0 ; c < B-R ; c++ , i-- ){
ans += 1LL*abs(r[R-1]-b[i]);
}
}
return ans;
}
# | 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... |