제출 #406684

#제출 시각아이디문제언어결과실행 시간메모리
406684daniel920712전선 연결 (IOI17_wiring)C++14
7 / 100
45 ms23864 KiB
#include "wiring.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
long long N,M;
long long DP[205][205];
bool have[205][205]={0};
vector < int > x,y;
long long F(long long a,long long b)
{
    if(a==N&&b==M) return 0;
    if(a==N||b==M) return 1e18;
    if(have[a][b]) return DP[a][b];
    have[a][b]=1;
    DP[a][b]=(long long) abs(y[b]-x[a])+min(min(F(a+1,b+1),F(a+1,b)),F(a,b+1));
    return DP[a][b];
}
long long min_total_length(vector< int > r, vector < int > b)
{
    N=r.size();
    M=b.size();
    x=r;
    y=b;
    return F(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...