Delivering Problem Sheets
Time limit2sMemory limit1024 MB
Given N points and Q query points in 11 dimensions, report for each query the maximum Manhattan distance to any of the N points.
- Level
Medium6 of 10
- Topics
- Math, Bit manipulation, Brute force, Implementation
- Solved
- No attempts yet
Problem
Gyo-jun felt unsatisfied with the online SNUPC 2020, so he decided to deliver the problem sheets directly to the homes of the contest participants.
As you know, this universe has 11 dimensions, so a participant's home is a point in 11-dimensional coordinates, . To move around in this universe you have to use the roads that run along the coordinate axes, so the distance needed to travel between two points and is as follows.
Gyo-jun will park the car carrying the problem sheets in one place and then deliver them. The 11-dimensional world has parking lots, and a parking lot is also a point in the 11-dimensional coordinate system, .
Carrying the problem sheets by hand is hard, so for each parking lot location Gyo-jun wants to know the distance to the farthest participant's home. He thought this problem was not bad, so he is going to write it on the problem sheet too and bring it to you.
Input
The first line of the input gives the number of participants and the number of parking lots , separated by a space.
Each of the next lines gives the coordinates of a participant's home, . Specifically, line gives the integers , , that represent the coordinates of participant 's home, separated by spaces.
Each of the lines starting from line gives the coordinates of a parking lot, . Specifically, line gives the integers , , that represent the coordinates of parking lot , separated by spaces.
Output
Print the answers over lines. On line , print the distance from parking lot to the farthest participant's home.