J Programming Tutors

J Programming Tutors

You are the founder of the Bruce Arden Programming Collective, which is a tutoring programme that matches experienced programmers with newbies to teach them. You have N students and N tutors, but now you have to match them up. Since the students will have to travel to their tutors’ houses from their own (or vice versa) you decide to do your matching based on travel distance.
Picture by Damien Pollet via Flickr
Minimising overall distance doesn’t seem fair; it might happen that one student has to travel a huge distance while all the other students get a tutor very close by, even though the tutors could have been split up so that each gets a tutor that is at least somewhat close.
Thus, you opt to minimise the distance travelled by the student who is worst off; one pairing of students to tutors is better than another if the student who has to travel farthest in the first pairing has to travel less far than the student who has to travel farthest in the second pairing.
Because the students live in a city, the distance that a student needs to travel is not the literal distance between them and their tutor. Instead, the distance between points (X, Y ) and (X′,Y′) in the city is
|X −X′|+|Y −Y′|.
Input
The first line of the input contains an integer N, with 1 ≤ N ≤ 100, the number of students and the number of tutors to pair up.
Then, there are N lines, each with two space separated integers with absolute value at most 108, which give the locations of the N students.
These are followed by N lines, each with two space separated integers with absolute value at most 108, which give the locations of the N tutors.
Note that it is possible for students and/or tutors to have identical locations (they may share a house).
Output
Output a single line containing a single integer K, where K is the least integer such that there exists a pairing of students to tutors so that no pair has distance greater than K between them.
22 Problem J: Programming Tutors
Sample Input 1 Sample Output 1
22 00
03
02
05
Sample Input 2 Sample Output 2
42 01
02
03
04 10 11 12 13
Sample Input 3
Sample Output 3
35 05
52
45
33 52 52
Sample Input 4
Sample Output 4
2 10 00
05
-1 4
83

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值