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;
using ll = long long;
#define sz(x) ((int)x.size())
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n,m;
vector<ll>R,B;
ll solve() {
ll ans = 0;
if(n >= m) {
for(int i = 0; i < n - m; ++i)
ans += R[i] - B[0];
for(int i = 0; i < m; ++i)
ans += R[n - m + i] - B[i];
ans = -ans;
}
else {swap(n,m), swap(R, B); return solve();}
return ans;
}
ll min_total_length(vector<int> r, vector<int> b) {
n = sz(r);
m = sz(b);
R.resize(n),B.resize(m);
for(int i=0;i<n;++i)R[i]=r[i];
for(int i=0;i<m;++i)B[i]=b[i];
return solve();
}
# | 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... |