Submission #101957

# Submission time Handle Problem Language Result Execution time Memory
101957 2019-03-21T07:41:12 Z tim25871014 Wiring (IOI17_wiring) C++17
0 / 100
2 ms 384 KB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;

long long min_total_length(vector<int> r, vector<int> b){
    int n=r.size(),m=b.size();
    int minn=min(n,m);
    
    if(n<=200 && m<=200){
        
        int dp[210][210];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+
                    abs(r[i]-b[j]);
        return dp[n-1][m-1];
    }
    
    long long ans=0;
    for(int i=0;i<minn;i++)
        ans+=b[m-i-1]-r[i];
    
    for(int i=minn;i<n;i++)
        ans+=b[0]-r[i];
    
    for(int i=minn;i<m;i++)
        ans+=b[m-i-1]-r[n-1];
    
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '25859', found: '21828'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '904', found: '326'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '316', found: '188'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB 3rd lines differ - on the 1st token, expected: '27', found: '19'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '25859', found: '21828'
2 Halted 0 ms 0 KB -