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;
#define N 402
const long long INF = 1e18;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int n = r.size();
int m = b.size();
long long ans = 0;
for (int i = 0; i < min(n, m); i++) {
ans += abs(r[i] - b[i]);
}
for (int i = min(n, m); i < max(n, m); i++) {
if (n < m) {
ans += abs(r[n - 1] - b[i]);
} else {
ans += abs(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... |