이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
int min_total_length(vector<signed> r, vector<signed> b) {
int nbRouges = r.size();
int nbBleus = b.size();
vector<vector<int>> dp(nbRouges, vector<int>(nbBleus));
for (int iRouge = 0; iRouge < nbRouges; ++iRouge)
for (int iBleu = 0; iBleu < nbBleus; ++iBleu) {
dp[iRouge][iBleu] = abs(r[iRouge] - b[iBleu]);
int toAdd = 1e18;
if (!iRouge and !iBleu)
toAdd = 0;
if (iRouge and iBleu)
toAdd = min(toAdd, dp[iRouge - 1][iBleu - 1]);
if (iRouge)
toAdd = min(toAdd, dp[iRouge - 1][iBleu]);
if (iBleu)
toAdd = min(toAdd, dp[iRouge][iBleu - 1]);
dp[iRouge][iBleu] += toAdd;
// cout << iRouge << ' ' << iBleu << ' ' << dp[iRouge][iBleu] << endl;
}
return dp[nbRouges - 1][nbBleus - 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... |