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<bits/stdc++.h>
using namespace std;
#define sz size()
typedef long long ll;
#define all(x) (x).begin(),(x).end()
long long min_total_length(std::vector<int> r, std::vector<int> b) {
ll n = r.sz, m = b.sz;
sort(all(r)); reverse(all(r)); sort(all(b));
ll l1 = 0, l2 = 0;
ll ans = 0;
while(l1<n&&l2<m)
{
ans+=b[l2]-r[l1];
l1++,l2++;
}
if(l1<n)
{
for(int i = l1 ; i < n; i++)
{
ans+= b[0]-r[i];
}
}
else
{
for(int i = l2; i < m; i++)
ans+=b[i]-r[0];
}
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... |