Board Meeting
Time limit60sMemory limit1024 MB
Find a meeting cell that minimizes the total Chebyshev distance to N kings whose number and coordinates are unknown to you.
- Level
Medium6 of 10
- Topics
- Math, Binary search, Implementation
- Solved
- No attempts yet
Problem
Note that it is not necessary to know anything about the rules of chess to solve this problem.
There are kings on an infinite chessboard (a two-dimensional grid), located in cells with coordinates . Neither nor the kings' coordinates are known to you. You do know the following:
- is at least 1 and at most .
- No king's coordinates ( or ) have an absolute value exceeding .
- The kings occupy different cells.
The kings want to meet in a single cell of the board. If cell is chosen as the meeting cell, the -th king needs moves to get there. The total number of moves is the sum of these values over all . The exact path each king takes does not matter. Only the start and end cells matter, and the move count can always be computed with the formula above.
Constraints
- .
- .
- for all .
- for all .
- The pairs are distinct.
- for all .
- for all .
- .