제출 #425624

#제출 시각아이디문제언어결과실행 시간메모리
425624Rouge_Hugo전선 연결 (IOI17_wiring)C++14
7 / 100
31 ms9264 KiB
#include "wiring.h" #include<bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; vector<ll>r,b;int n,m; ll dp[209][209]; ll go(int x,int y) { ll z=abs(r[x]-b[y]);return z; } ll d(int x,int y) { if(x>n)return 1e18; if(y>m)return 1e18; if(x==n&&y==m)return 0; ll &u=dp[x][y]; if(u!=-1)return u; u=1e18;ll z=go(x,y); u=min(d(x+1,y)+z,d(x,y+1)+z); u=min(u,d(x+1,y+1)+z); return u; } long long min_total_length(vector<int> R,vector<int> B) { memset(dp,-1,sizeof dp); n=R.size();m=B.size(); for(int i=0;i<m;i++){ b.pb(B[i]); } for(int i=0;i<n;i++){ r.pb(R[i]); } return d(0,0); }
#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...