Submission #33344

# Submission time Handle Problem Language Result Execution time Memory
33344 2017-10-24T12:00:20 Z mohammad_kilani Wiring (IOI17_wiring) C++14
0 / 100
26 ms 5736 KB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 500;
vector<int> r , b;
long long dp[N][N];
int n , m;
long long solve(int i,int j){
	if(i == n && j == m) return 0;
	if(i == n || j == m) return 1e18;
	if(dp[i][j] != -1) return dp[i][j];
	dp[i][j] = 1e18;
	long long cur = 0 ;
	for(int k=j;k<m;k++){
		cur += abs(r[i] - b[k]);
		dp[i][j] = min(dp[i][j],cur + solve(i+1,k+1));
	}
	return dp[i][j];
}




long long min_total_length(std::vector<int> R, std::vector<int> B) {
	memset(dp,-1,sizeof(dp));
	r = R;
	b = B;
	if(r.size() > b.size()) swap(r,b);
	n = r.size();
	m = b.size();
	return solve(0,0);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3972 KB Output is correct
2 Incorrect 0 ms 3972 KB 3rd lines differ - on the 1st token, expected: '14340', found: '17422'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3972 KB Output is correct
2 Correct 6 ms 3972 KB Output is correct
3 Runtime error 26 ms 5736 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3972 KB Output is correct
2 Incorrect 0 ms 3972 KB 3rd lines differ - on the 1st token, expected: '17703', found: '19052'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3972 KB 3rd lines differ - on the 1st token, expected: '27', found: '30'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3972 KB Output is correct
2 Incorrect 0 ms 3972 KB 3rd lines differ - on the 1st token, expected: '14340', found: '17422'
3 Halted 0 ms 0 KB -