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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
int N, M;
ll A[MAXN+10], B[MAXN+10];
ll ans=0;
ll min_total_length(vector<int> _A, vector<int> _B)
{
N=_A.size(); M=_B.size();
for(int i=1; i<=N; i++) A[i]=_A[i-1];
for(int i=1; i<=M; i++) B[i]=_B[i-1];
for(int i=1; i<N; i++)
{
ans+=(A[i+1]-A[i])*i;
}
for(int i=1; i<M; i++)
{
ans+=(B[i+1]-B[i])*(M-i);
}
ans+=(B[1]-A[N])*max(N, M);
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... |