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>
using namespace std;
#define pi pair<int, int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
typedef long long ll;
ll min_total_length(vector<int> r, vector<int> b) {
int n = r.size();
int m = b.size();
sort(r.begin(), r.end());
sort(b.begin(), b.end());
int mn = min(n, m);
ll ans = 0;
for (int i = 0; i < mn; i++) {
ans += (b[i] - r[n - 1 - i]);
}
for (int i = mn; i < max(n, m); i++) {
if (i < m) ans += (b[i] - r[0]);
else ans += (b[0] - r[n - 1 - i]);
}
return ans;
}
// int main() {
// ios::sync_with_stdio(0);
// cin.tie(0);
// return 0;
// }
# | 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... |