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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 205;
const ll oo = 1e18;
bool mark[N];
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int n = r.size();
int m = b.size();
if (n < m) {
swap(n, m);
swap(r, b);
}
ll rs = 0;
for (int i = 0; i < m; ++i) {
ll Min = oo;
int pos = -1;
for (int j = 0; j < n; ++j) if (!mark[j]) {
if (abs(r[j] - b[i]) < Min) {
Min = abs(r[j] - b[i]);
pos = j;
}
}
mark[pos] = 1;
rs += Min;
}
for (int i = 0; i < n; ++i) if (!mark[i]) {
ll Min = oo;
for (int j = 0; j < m; ++j) Min = min(Min, (ll)abs(r[i] - b[j]));
rs += Min;
}
return rs;
}
# | 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... |