Submission #33352

#TimeUsernameProblemLanguageResultExecution timeMemory
33352mohammad_kilaniWiring (IOI17_wiring)C++14
7 / 100
36 ms6324 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; const int N = 500; vector<int> r , b; long long dp[N][N]; int n , m; long long solve(int i,int j){ if(i == n && j == m) return 0; if(j == m) return 1e18; if(dp[i][j] != -1) return dp[i][j]; dp[i][j] = min(solve(i+1,j),min(solve(i,j+1),solve(i+1,j+1))) + abs(r[i] - b[j]); return dp[i][j]; } long long min_total_length(std::vector<int> R, std::vector<int> B) { memset(dp,-1,sizeof(dp)); r = R; b = B; n = r.size(); m = b.size(); return solve(0,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...