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;
for(int i = 0; i < n - 1; ++i)
ans += B[0] - R[i];
for(int i = 1; i < m; ++i)
ans += B[i] - R[n - 1];
if(n == 1) ans += B[0] - R[0];
else if(m == 1) ans += B[0] - R[0];
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... |