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;
using ll = long long;
using vi = vector<ll>;
using pi = pair<long long, long long>;
#define pb emplace_back
ll min_total_length(vector<int> r, vector<int> b) {
ll ans = 0;
int n = r.size();
int m = b.size();
for(int i = 0; i < n; ++i) {
if(m - i - 1 < 0) break;
ans += abs(r[i] - b[m - i - 1]);
}
if(n < m) {
for(int i = 0; i < m - n; ++i) {
ans += b[i] - r[n - 1];
}
} else if(m < n) {
for(int i = m; i < n; ++i) {
ans += b[0] - r[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... |