이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define F0R(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define R0F(i,b) ROF(i,0,b)
#define all(x) begin(x),end(x)
#define sz(x) int(x.size())
#define pb push_back
#define rsz resize
#define trav(a,x) for(auto&a :x)
#define fi first
#define se second
int const n=200+3;
ll dp[n][n];
ll const INF=1e18;
ll min_total_length(vi r, vi b) {
int n=sz(r);
int m=sz(b);
dp[0][0]=0;
fill(dp[0],dp[0]+m+1,INF);
F0R(i,n+1)dp[i][0]=INF;
dp[0][0]=0;
FOR(i,1,n+1)
{
FOR(j,1,m+1)
{
dp[i][j]=4e18;
dp[i][j]=min(dp[i][j],dp[i-1][j] + abs(r[i-1]-b[0]));
dp[i][j]=min(dp[i][j],dp[i][j-1] + abs(r[i-1]-b[j-1]));
dp[i][j]=min(dp[i][j],dp[i-1][j-1] + abs(r[i-1]-b[j-1]));
}
}
return dp[n][m];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |