Submission #1061004

#TimeUsernameProblemLanguageResultExecution timeMemory
1061004Sir_Ahmed_ImranWiring (IOI17_wiring)C++17
7 / 100
19 ms5564 KiB
                                    ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define MAXN 201
ll dp[MAXN][MAXN];
ll min_total_length(vector<int> r,vector<int> b){
    ll n,m,o;
    n=r.size();
    m=b.size();
    for(ll i=0;i<=n;i++)
        for(ll j=0;j<=m;j++)
            dp[i][j]=1e18;
    dp[0][0]=0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            o=0;
            for(ll k=1;k<=j;k++){
                o+=abs(r[i-1]-b[j-k]);
                dp[i][j]=min(dp[i][j],dp[i-1][j-k]+o);
            }
            o=0;
            for(ll k=1;k<=i;k++){
                o+=abs(r[i-k]-b[j-1]);
                dp[i][j]=min(dp[i][j],dp[i-k][j-1]+o);
            }
        }
    }
    return dp[n][m];
}
#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...