Submission #434231

#TimeUsernameProblemLanguageResultExecution timeMemory
434231OttoTheDinoWiring (IOI17_wiring)C++17
7 / 100
167 ms262148 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; #define rep(i,s,e) for (int i = s; i <= e; ++i) #define rrep(i,s,e) for (int i = s; i >= e; --i) #define pb push_back #define pf push_front #define fi first #define se second #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<double> vd; typedef vector<string> vs; typedef vector<char> vc; typedef vector<ll> vll; ll min_total_length(vi r, vi b) { int n = r.size(), m = b.size(); ll dp[n+1][m+1] = {}; rep (i,1,n) rep (j,1,m) { ll mi = LLONG_MAX; if (i==1 && j==1) mi = 0; if (i>1) mi = min(mi, dp[i-1][j]); if (j>1) mi = min(mi, dp[i][j-1]); if (i>1 && j>1) mi = min(mi, dp[i-1][j-1]); dp[i][j] = mi+abs(r[i-1]-b[j-1]); } return dp[n][m]; }
#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...