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 ll long long
ll min_total_length(vector<int> r, vector<int> b){
ll ans = 0;
int n = r.size();
int m = b.size();
if(n < m){
for(int i =0; i<n; i++){
ans+= b[i] - r[i];
}
for(int i = n; i < m; i++)
ans+= b[i] - r[n-1];
}
else{
for(int i =0; i<m; i++){
ans+= b[i] - r[i];
}
for(int i = m; i < n; i++)
ans+= b[0] - r[i];
}
return ans;
}
/*
int main(){
//int n, m; cin >> n >> m;
int r[5] = {1,2,3,4,5};
int b[5] = {2,3,4,5,6};
cout << min_total_length(r, b)<<endl;
}*/
# | 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... |