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 <math.h>
using namespace std;
typedef long long ll;
int n, m;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
n = r.size();
m = b.size();
if (r.back() < b.front()) {
ll ans = 0;
int rfocal = r.back();
int bfocal = b.front();
int i = 0;
// while (i < n && i < m) {
// int rpoint = r[n - 1 - i];
// int bpoint = b[i];
// ans += abs(rpoint - bpoint);
// i++;
// }
for (int cur = i; cur < n; cur++) {
ans += abs(r[n - 1 - i] - bfocal);
}
for (int cur = i; cur < m; cur++) {
ans += abs(b[i] - rfocal);
}
return ans;
}
return -1;
}
# | 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... |