제출 #469342

#제출 시각아이디문제언어결과실행 시간메모리
469342peijar전선 연결 (IOI17_wiring)C++17
0 / 100
1 ms292 KiB
#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 = iBleu ? dp[iRouge][iBleu - 1] : 0; if (iRouge) { toAdd = min(toAdd, dp[iRouge - 1][iBleu]); if (iBleu) toAdd = min(toAdd, dp[iRouge - 1][iBleu - 1]); } dp[iRouge][iBleu] += toAdd; // cout << iRouge << ' ' << iBleu << ' ' << dp[iRouge][iBleu] << endl; } return dp[nbRouges - 1][nbBleus - 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...