Submission #362375

#TimeUsernameProblemLanguageResultExecution timeMemory
362375MoldovanAndrei1Wiring (IOI17_wiring)C++14
0 / 100
26 ms4588 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; } int 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 sum=0; for(int t = j-1; t >-1; t--) { sum+=maxim(r[i]-b[t+1],b[t+1]-r[i]); dp[i][j] = minim(dp[i][j],dp[i-1][t] + sum); } } 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...