Submission #420042

#TimeUsernameProblemLanguageResultExecution timeMemory
420042chirathnirodhaWiring (IOI17_wiring)C++17
20 / 100
32 ms3116 KiB
#include "wiring.h" #include<bits/stdc++.h> using namespace std; int dp[500][500]; long long min_total_length(vector<int> r, vector<int> b) { int n=r.size(),m=b.size(); if(n<=200 && m<=200){ dp[0][0]=abs(r[0]-b[0]); for(int i=1;i<m;i++)dp[0][i]=dp[0][i-1]+abs(r[0]-b[i]); for(int i=1;i<n;i++)dp[i][0]=dp[i-1][0]+abs(r[i]-b[0]); for(int i=1;i<n;i++) for(int j=1;j<m;j++) dp[i][j]=min(min(dp[i][j-1],dp[i-1][j]),dp[i-1][j-1])+abs(r[i]-b[j]); return dp[n-1][m-1]; } else{ int jj=0; int ii=0; long long sum=0; for(ii;ii<n && jj<m;ii++,jj++){ sum+=b[jj]-r[ii]; } for(ii;ii<n;ii++)sum+=b[0]-r[ii]; for(jj;jj<m;jj++)sum+=b[jj]-r[n-1]; return sum; } }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:19:11: warning: statement has no effect [-Wunused-value]
   19 |       for(ii;ii<n && jj<m;ii++,jj++){
      |           ^~
wiring.cpp:22:11: warning: statement has no effect [-Wunused-value]
   22 |       for(ii;ii<n;ii++)sum+=b[0]-r[ii];
      |           ^~
wiring.cpp:23:11: warning: statement has no effect [-Wunused-value]
   23 |       for(jj;jj<m;jj++)sum+=b[jj]-r[n-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...