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 N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define sz() size()
#define pb push_back
#define ll long long
using namespace std;
ll ans;
ll min_total_length(vector<int>a, vector<int>b){
ll n=a.sz();
ll m=b.sz();
ll x=0, y=0;
while(x<n and y<m){
ans+=b[y]-a[x];
x++, y++;
}
for(int i=x; i<n; i++)
ans+=b[0]-a[i];
for(int i=y; i<m; i++)
ans+=b[i]-a[n-1];
return ans;
}
/*
int main(){
int n, m, x;
vector<int>a, b;
cin>>n>>m;
for(int i=1; i<=n; i++)
cin>>x, a.pb(x);
for(int i=1; i<=m; i++)
cin>>x, b.pb(x);
cout<<min_total_length(a, b);
}*/
# | 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... |