Submission #885955

#TimeUsernameProblemLanguageResultExecution timeMemory
885955waldiWiring (IOI17_wiring)C++17
7 / 100
150 ms262144 KiB
#include "wiring.h" #include <bits/stdc++.h> #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) #define ssize(x) (int((x).size())) #define all(x) (x).begin(),(x).end() #define inf 1000000000000000000ll using namespace std; typedef long long ll; ll min_total_length(vector<int> r, vector<int> b){ int n = ssize(r); int m = ssize(b); vector dp(n, vector(m, inf)); dp[0][0] = abs(r[0]-b[0]); REP(i, n) REP(j, m){ if(i+1 < n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + abs(r[i+1]-b[j])); if(j+1 < m) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + abs(r[i]-b[j+1])); if(i+1 < n && j+1 < m) dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + abs(r[i+1]-b[j+1])); } 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...