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 <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
long long N,M;
long long DP[205][205];
bool have[205][205]={0};
vector < int > x,y;
long long F(long long a,long long b)
{
if(a==N&&b==M) return 0;
if(a==N||b==M) return 1e18;
if(have[a][b]) return DP[a][b];
have[a][b]=1;
DP[a][b]=(long long) abs(y[b]-x[a])+min(min(F(a+1,b+1),F(a+1,b)),F(a,b+1));
return DP[a][b];
}
long long min_total_length(vector< int > r, vector < int > b)
{
N=r.size();
M=b.size();
x=r;
y=b;
return F(0,0);
}
# | 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... |