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"
#define ll long long
using namespace std ;
ll min_total_length(vector<int> r, vector<int> b)
{
ll sr = r.size();
ll sb = b.size();
sort(r.begin(),r.end());
sort(b.begin(),b.end());
ll c=0;
for(int i=0;i<min(sr,sb);i++)
{
c+=abs(r[i%sr]-b[i%sb]);
}
if(sb<sr){
for(int i = sb ;i<sr;i++ )
c+=abs(r[sr-1]-b[i]);
}
else for(int i = sr ;i<sb;i++ )
c+=abs(b[sb-1]-r[i]);
return c;
}
# | 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... |