public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n,H,W;
n = scanner.nextInt();
H = scanner.nextInt();
W = scanner.nextInt();
int[][] group = new int[n][2];
int[][] nums = new int[H + 1][W + 1];
for (int i = 0; i < n; i++) {
group[i][1] = scanner.nextInt();
}
for (int i = 0; i < n; i++) {
group[i][0] = scanner.nextInt();
}
int r = 0;
do {
markNums(nums, group, r, n);
r++;
} while (hasPath(nums));
System.out.println(r - 1);
}
// 标记数组中不可达的点
public static void markNums(int[][] nums, int[][] group, int r, int n) {
int row = nums.length;
int col = nums[0].length;
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
for (int k = 0; k < n; k++) {
if (isInBorder(group[k][0], group[k][1], i, j, r)) {
nums[i][j] = -1;
}
}
}
}
}
// 判断是否在黑洞内
public static boolean isInBorder(int x, int y, int x1, int y1, int r){
return (double)(x1 - x) * (x1 - x) + (double) (y1 - y) * (y1 - y) <= (double) r * r;
}
// 动规求能否到达终点
public static boolean hasPath(int[][] nums) {
int row = nums.length;
int col = nums[0].length;
boolean[][] visited = new boolean[row][col];
boolean block = false;
for (int i = 0; i < col; i++) {
if (nums[0][i] != -1 && !block) {
visited[0][i] = true;
} else {
block = true;
visited[0][i] = false;
}
}
block = false;
for (int i = 0; i < row; i++) {
if (nums[i][0] != -1 && !block) {
visited[i][0] = true;
} else {
block = true;
visited[i][0] = false;
}
}
for (int i = 1; i < row; i++) {
for (int j = 1; j < col; j++) {
if (nums[i][j] == -1) {
visited[i][j] = false;
} else {
visited[i][j] = visited[i -1][j] || visited[i][j - 1];
}
}
}
return visited[row - 1][col - 1];
}
#美团笔试##美团##笔经#