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 ll long long
#define sz(x) (ll)x.size()
#define endl "\n"
#define pb push_back
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
vi r, b;
long long min_total_length(vector<int> R, vector<int> B) {
ll n = sz(R), m = sz(B);
r.resize(n), b.resize(m);
for (ll i =0; i<n; i++){
r[i] = R[i];
}
for (ll i = 0; i<m; i++){
b[i] = B[i];
}
//subtask 2:
reverse(r.begin(), r.end());
ll ans = 0;
for (ll i =0; i<min(n,m); i++){
ans += abs(b[i] - r[i]);
}
if (n > m){
for (ll i =min(n,m); i<n; i++){
ans += abs(b[0]-r[i]);
}
}
else if (m > n){
for (ll i =min(n,m); i<m; i++){
ans += abs(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... |