Logo
(追記) (追記ここまで)

13470번 - Programming Tutors 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB21411910358.523%

문제

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.

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'|.

입력

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 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.

제한

예제 입력 1

2
0 0
0 3
0 2
0 5

예제 출력 1

2

예제 입력 2

4
0 1
0 2
0 3
0 4
1 0
1 1
1 2
1 3

예제 출력 2

2

예제 입력 3

3
0 5
5 2
4 5
3 3
5 2
5 2

예제 출력 3

5

예제 입력 4

2
0 0
0 5
-1 4
8 3

예제 출력 4

10

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2016 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /