Submission #1062734

#TimeUsernameProblemLanguageResultExecution timeMemory
1062734deeraWiring (IOI17_wiring)C++14
7 / 100
21 ms3932 KiB
#include <bits/stdc++.h> using namespace std; int d(int x, int y) {return abs(x - y);} long long min_total_length(vector<int> r, vector<int> b) { int n = r.size(), m = b.size(); if (b.back() < r.front()) { long long a = 0; for(int i: r) a += r.back() - i; for(int i: b) a += i - b.front(); return a + (b.front() - r.back()) * max(r.size(), b.size()); } if (n <= 200 && m <= 200) { int dp[201][201]; dp[0][0] = d(r[0], b[0]); for(int i = 1; i < n; i++) dp[i][0] = dp[i-1][0] + d(r[i], b[0]); for(int i = 1; i < m; i++) dp[0][i] = dp[0][i-1] + d(r[0], b[i]); for(int i = 1; i < n; i++) for(int j = 1; j < m; j++) dp[i][j] = min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}) + d(r[i], b[j]); return dp[n - 1][m - 1]; } }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
#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...