Submission #420725

#TimeUsernameProblemLanguageResultExecution timeMemory
420725AugustinasJucasWiring (IOI17_wiring)C++14
20 / 100
33 ms5120 KiB
#include <bits/stdc++.h> //#include "wiring.h" using namespace std; vector<int> r, b; const int inf = 1e9; long long linf = 1e18; long long dp[201][201] = {}; long long min_total_length(vector<int> r, vector<int> b) { int n = r.size(); int m = b.size(); for(int i = 0; i < 201; i++) for(int j = 0; j < 201; j++) dp[i][j] = linf; dp[0][0] = 0; if(r.back() < b[0]){ long long ret = 0; for(int i = 0; i < min(r.size(), b.size()); i++){ ret += b[i] - r[i]; } for(int i = min(r.size(), b.size()); i < r.size(); i++){ ret += b[0] - r[i]; } for(int i = min(r.size(), b.size()); i < b.size(); i++){ ret += b[i] - r.back(); } return ret; } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(i + j == 0) continue; dp[i][j] = min(dp[i][j], abs(r[i-1] - b[j-1]) + dp[i-1][j-1]); dp[i][j] = min(dp[i][j], abs(r[i-1] - b[j-1]) + dp[i-1][j]); dp[i][j] = min(dp[i][j], abs(r[i-1] - b[j-1]) + dp[i][j-1]); } } return dp[n][m]; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   16 |   for(int i = 0; i < min(r.size(), b.size()); i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~
wiring.cpp:19:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for(int i = min(r.size(), b.size()); i < r.size(); i++){
      |                                        ~~^~~~~~~~~~
wiring.cpp:22:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for(int i = min(r.size(), b.size()); i < b.size(); i++){
      |                                        ~~^~~~~~~~~~
#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...