Submission #72638

#TimeUsernameProblemLanguageResultExecution timeMemory
72638idan_izmirliWiring (IOI17_wiring)C++14
20 / 100
1081 ms3716 KiB
#include "wiring.h" using namespace std; long long inline mmin(long long a,long long b) { if(a<b) { return a; } return b; } long long inline mabs(long long a) { if(a<0) { return -a; } return a; } long long best[2][100000]; long long min_total_length(std::vector<int> r, std::vector<int> b) { if(r[r.size()-1]>b[0]) { for(int i=0;i<r.size();i++) { for(int j=0;j<b.size();j++) { best[i%2][j]=mabs(r[i]-b[j]); if(i==0) { if(j!=0) { best[i%2][j]+=best[i%2][j-1]; } } else if(j==0) { best[i%2][j]+=best[(i+1)%2][j]; } else { best[i%2][j]+=mmin(mmin(best[(i+1)%2][j],best[i%2][j-1]),best[(i+1)%2][j-1]); } } } return best[(r.size()+1)%2][b.size()-1]; } long long result=0; long long blue,red; for(int i=0;(i<r.size())||(i<b.size());i++) { if(i>=r.size()) { red=r[r.size()-1]; } else { red=r[i]; } if(i>=b.size()) { blue=b[0]; } else { blue=b[b.size()-1-i]; } result+=blue-red; } return result; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:31:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<r.size();i++)
               ~^~~~~~~~~
wiring.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j=0;j<b.size();j++)
                ~^~~~~~~~~
wiring.cpp:57:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;(i<r.size())||(i<b.size());i++)
               ~^~~~~~~~~
wiring.cpp:57:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;(i<r.size())||(i<b.size());i++)
                             ~^~~~~~~~~
wiring.cpp:59:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i>=r.size())
      ~^~~~~~~~~~
wiring.cpp:67:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i>=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...