Submission #430612

#TimeUsernameProblemLanguageResultExecution timeMemory
430612fskaricaWiring (IOI17_wiring)C++14
7 / 100
34 ms5172 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 210; long long dp[MAX][MAX]; int n, m; long long min_total_length(std::vector<int> r, std::vector<int> b) { n = r.size(); m = b.size(); for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = 1e18; } } dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = min(dp[i][j], dp[i - 1][j]); dp[i][j] = min(dp[i][j], dp[i][j - 1]); dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]); dp[i][j] += abs(r[i - 1] - b[j - 1]); } } // for (int i = 0; i <= n; i++) { // for (int j = 0; j <= m; j++) { // if (dp[i][j] == 1e9) { // cout << "- "; // } // else { // cout << dp[i][j] << " "; // } // } // cout << "\n"; // } return dp[n][m]; } //int main() { // cin >> n >> m; // // vector <int> a; // vector <int> b; // // int x; // for (int i = 0; i < n; i++) { // cin >> x; // a.push_back(x); // } // // for (int i = 0; i < m; i++) { // cin >> x; // b.push_back(x); // } // // cout << min_total_length(a, b) << "\n"; // // return 0; //}
#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...