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 endl "\n"
// #define int long long
typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7 ;
const int N = 10000010 ;
ll dp[222][222];
ll min_total_length(vector<int> r, vector<int> b) {
ll nr = r.size() , nb = b.size();
for(int i = 0 ; i < nr; ++i)
for(int j = 0 ; j < nb; ++j){
dp[i][j] = 0;
if(i && j){
dp[i][j] = min(dp[i - 1][j - 1] , min(dp[i][j - 1] , dp[i - 1][j] ));
}else if(i) dp[i][j] = dp[i - 1][j];
else if(j) dp[i][j] = dp[i][j - 1];
// cout << dp[i][j] << ' ' << b[j] << ' ' << r[i] << endl;
dp[i][j] += abs(b[j] - r[i]);
}
return dp[nr- 1][nb - 1];
}
# | 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... |