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 mk make_pair
#define sc second
#define fr first
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)
using namespace std;
const long long INF = (int)1e18 + 7;
const int N = (int)1e5 + 12;
const int mod = 1000000007;
int dp[222][222] , red[N], blue[N];
long long min_total_length(std::vector<int > r, std::vector<int > b){
int n = r.size(), m = b.size();
memset(dp,0x3f3f3f3f,sizeof(dp));
for(int i = 1;i <= n; i++){
red[i] = r[i - 1];
}
for(int i = 1;i <= m; i++){
blue[i] = b[i - 1];
}
dp[0][0] = 0;
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
dp[i][j] = min({dp[i - 1][j - 1],dp[i - 1][j],dp[i][j - 1]}) + abs(red[i] - blue[j]);
}
}
return dp[n][m];
}
# | 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... |