import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int n = sc.nextInt();
int m = sc.nextInt();
long[] stu = new long[n*2];
long[] dis = new long[m*2];
for (int i = 0; i < n*2; i=i+2) {
stu[i] = sc.nextLong();
stu[i+1] = sc.nextLong();
}
for (int i = 0; i < m*2; i=i+2) {
dis[i] = sc.nextLong();
dis[i+1] = sc.nextLong();
}
//存循环结果的值
long[] res = new long[m];
int cnt = 0;
long min = 0;
for (int i = 0; i < n*2; i=i+2) {
for (int j = 0; j < m*2; j=j+2) {
res[cnt] = Math.abs(stu[i]-dis[j])+Math.abs(stu[i+1]-dis[j+1]);
cnt++;
}
min = res[0];
for (int k = 0; k < cnt; k++) {
if(min > res[k]) min = res[k];
}
for (int j = 0; j < cnt; j++) {
if(min == res[j]) {
System.out.println(j+1);
break;
}
}
cnt=0;
}
}
}
}
There are N studentsand M checkpoints
最新推荐文章于 2024-10-06 20:16:20 发布