제출 #723040

#제출 시각아이디문제언어결과실행 시간메모리
723040nihaddhuseynli전선 연결 (IOI17_wiring)C++14
20 / 100
24 ms3768 KiB
#include "wiring.h" #include <bits/stdc++.h> typedef long long int ll; using namespace std; long long min_total_length(std::vector<int> r, std::vector<int> b) { ll n=r.size(); ll m=b.size(); ll ans=0,ans1=INT_MAX; if(n<=200 && m<=200) { long long int dp[n+1][m+1]; for(int i =0;i<=n;i++) { for(int j =0;j<=m;j++) { dp[i][j]=INT_MAX; } } for(int i =0;i<n;i++) { for(int j =0;j<m;j++) { if(i==0) { if(j==0) { dp[i][j]=0;; } else { dp[i][j]=dp[i][j-1]; } } else { dp[i][j] = dp[i-1][j]; if (j>0){ dp[i][j] = min({dp[i][j],dp[i][j-1],dp[i-1][j-1]}); } } if(dp[i][j]!=INT_MAX) { dp[i][j]+=abs(r[i]-b[j]); } } } return dp[n-1][m-1]; } else { for(ll i =0;i<n;i++) { ans+=(ll)(r[n-1]-r[i]); } for(ll i =0;i<m;i++) { ans+=(ll)(b[i]-b[0]); } ans+=((max(ll(n),(ll)m))*(ll)(b[0]-r[n-1])); } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:8:11: warning: unused variable 'ans1' [-Wunused-variable]
    8 |  ll ans=0,ans1=INT_MAX;
      |           ^~~~
#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...