답안 #113475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113475 2019-05-25T21:31:13 Z E869120 전선 연결 (IOI17_wiring) C++14
7 / 100
200 ms 75084 KB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;

long long N, M, A[200009], B[200009], dp[2009][2009];

long long solve_subtask1() {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) dp[i][j] = (1LL << 60);
	}
	dp[0][0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + abs(A[i] - B[j]));
			if (j >= 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + abs(A[i] - B[j - 1]));
			if (i >= 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + abs(A[i - 1] - B[j]));
		}
	}
	return dp[N][M];
}

long long min_total_length(vector<int> r, vector<int> b) {
	N = r.size(); M = b.size();
	for (int i = 0; i < N; i++) A[i] = r[i];
	for (int i = 0; i < M; i++) B[i] = b[i];
	
	return solve_subtask1();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 5 ms 1408 KB Output is correct
11 Correct 3 ms 1408 KB Output is correct
12 Correct 3 ms 1408 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 3 ms 1408 KB Output is correct
15 Correct 3 ms 1408 KB Output is correct
16 Correct 3 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 1280 KB Output is correct
3 Runtime error 146 ms 73788 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Runtime error 200 ms 75084 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Runtime error 194 ms 74392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 1408 KB Output is correct
8 Correct 3 ms 1408 KB Output is correct
9 Correct 3 ms 1408 KB Output is correct
10 Correct 5 ms 1408 KB Output is correct
11 Correct 3 ms 1408 KB Output is correct
12 Correct 3 ms 1408 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 3 ms 1408 KB Output is correct
15 Correct 3 ms 1408 KB Output is correct
16 Correct 3 ms 1408 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 1280 KB Output is correct
19 Runtime error 146 ms 73788 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Halted 0 ms 0 KB -