Submission #71383

#TimeUsernameProblemLanguageResultExecution timeMemory
71383KmcodeWiring (IOI17_wiring)C++14
7 / 100
1086 ms263168 KiB
#include<bits/stdc++.h> //#include "books.h" using namespace std; #define MAX 5002 int n; long long int dp[MAX][MAX]; long long min_total_length(std::vector<int> r, std::vector<int> b) { for(int i=0;i<r.size();i++){ for(int j=0;j<b.size();j++){ dp[i][j]=LLONG_MAX; } } dp[0][0]=abs(r[0]-b[0]); for(int i=0;i<r.size();i++){ for(int j=0;j<b.size();j++){ if(i+1<r.size()){ dp[i+1][j]=min(dp[i+1][j],dp[i][j]+abs(r[i+1]-b[j])); } if(j+1<b.size()){ dp[i][j+1]=min(dp[i][j+1],dp[i][j]+abs(r[i]-b[j+1])); } if(i+1<r.size()&&j+1<b.size()){ dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+abs(r[i+1]-b[j+1])); } } } return dp[r.size()-1][b.size()-1]; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++){
              ~^~~~~~~~~
wiring.cpp:10:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<b.size();j++){
               ~^~~~~~~~~
wiring.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<r.size();i++){
              ~^~~~~~~~~
wiring.cpp:16:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<b.size();j++){
               ~^~~~~~~~~
wiring.cpp:17:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()){
       ~~~^~~~~~~~~
wiring.cpp:20:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j+1<b.size()){
       ~~~^~~~~~~~~
wiring.cpp:23:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()&&j+1<b.size()){
       ~~~^~~~~~~~~
wiring.cpp:23:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+1<r.size()&&j+1<b.size()){
                     ~~~^~~~~~~~~
#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...