Submission #362442

#TimeUsernameProblemLanguageResultExecution timeMemory
362442MoldovanAndrei1Wiring (IOI17_wiring)C++14
7 / 100
43 ms6508 KiB
#include <bits/stdc++.h> #include "wiring.h" long long dp[205][205];/// am folosit primele i pozitii si primele j pozitii long long maxim(long long a, long long b) { if(b>a)return b; return a; } long long minim(long long a, long long b) { if(b>a)return a; return b; } long long min_total_length(std::vector<int> r, std::vector<int> b) { int n = r.size() , m = b . size(); for(int i=0;i<n;i++) for(int j=0;j<m;j++) dp[i][j]=9999999999999; for(int i = 0 ; i < m ; i++ ) dp[0][i]=dp[0][i-1]+maxim(b[i]-r[0],r[0]-b[i]); for(int i = 0 ; i < n ; i++ ) dp[i][0]=dp[i-1][0] + maxim(r[i]-b[0],b[0]-r[i]); for(int i = 1 ; i < n ; i++) for(int j = 1 ; j < m ; j++) { long long t = minim(dp[i-1][j-1],dp[i][j-1]); t=minim(t,dp[i-1][j]); dp[i][j]=t+maxim(r[i]-b[j],b[j]-r[i]); } return dp[n-1][m-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...