답안 #299360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299360 2020-09-14T19:40:35 Z medk 전선 연결 (IOI17_wiring) C++14
0 / 100
34 ms 4216 KB
#include <bits/stdc++.h>
#include "wiring.h"

#define ll long long
#define pb push_back
#define x first
#define y second
#define all(u) u.begin(),u.end()
#define sz(u) (int)(u.size())

using namespace std;

ll min_total_length(vector<int> a, vector<int> b){
    int sza=sz(a), szb=sz(b);
    if(szb>sza) swap(a,b), swap(sza,szb);
    int diff=sza-szb;
    ll dp[sza+1][diff+1];
    for(int i=0;i<=sza;i++) for(int j=0;j<=diff;j++) dp[i][j]=1e18;
    dp[0][0]=0;
    for(int i=1;i<=sza;i++){
        for(int j=0;j<=diff && i-1-j>=0;j++){
            if(dp[i-1][j]<1e17) if(i-1-j<szb) dp[i][j]=dp[i-1][j]+(ll)abs(a[i-1]-b[i-1-j]);
            ll mn=2e18;
            for(int k=0;k<szb;k++) mn=min(mn,(ll)abs(a[i-1]-b[k]));
            if(j>0) dp[i][j]=min(dp[i][j], dp[i-1][j-1]+mn);
        }
    }
    return dp[sza][diff];
}
/*
int main(){
    cout<<min_total_length({1,2,3,7},{0,4,5,9,10});
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '14340', found: '17422'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Runtime error 34 ms 4216 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '17703', found: '19052'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '27', found: '30'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '14340', found: '17422'
3 Halted 0 ms 0 KB -