首页 > 试题广场 >

解救小易

[编程题]解救小易
  • 热度指数:26049 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
有一片1000*1000的草地,小易初始站在(1,1)(最左上角的位置)。小易在每一秒会横向或者纵向移动到相邻的草地上吃草(小易不会走出边界)。大反派超超想去捕捉可爱的小易,他手里有n个陷阱。第i个陷阱被安置在横坐标为xi ,纵坐标为yi 的位置上,小易一旦走入一个陷阱,将会被超超捕捉。你为了去解救小易,需要知道小易最少多少秒可能会走入一个陷阱,从而提前解救小易。

输入描述:
第一行为一个整数n(n ≤ 1000),表示超超一共拥有n个陷阱。
第二行有n个整数xi,表示第i个陷阱的横坐标
第三行有n个整数yi,表示第i个陷阱的纵坐标
保证坐标都在草地范围内。


输出描述:
输出一个整数,表示小易最少可能多少秒就落入超超的陷阱
示例1

输入

3
4 6 8
1 2 1

输出

3
头像 白伟仝
发表于 2020-07-24 16:58:55
曼哈顿距离 = (x + y) - (1 + 1): import java.util.*; public class Main { public static void main(String[] args) throws Exception{ Scanner sc = n 展开全文
头像 叶孤城_
发表于 2023-08-04 18:09:23
#include <stdio.h> int main() { int arr[1000][1000]={0}; int x[100]={0}; int y[100]={0}; int n=0; scanf("%d",&am 展开全文
头像 bao_hu_yuan_zhang
发表于 2024-03-19 22:09:50
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int i=0; int n=0; cin> 展开全文
头像 whoway
发表于 2021-03-24 20:49:52
#include<bits/stdc++.h> using namespace std; const int maxn=1e3+5; int solve[2][maxn]; int n; int main() { while( ~scanf("%d",&n) ) 展开全文