#C10522. Drone Navigation Commands
Drone Navigation Commands
Drone Navigation Commands
You are given a grid with dimensions \(N\) and \(M\), and \(K\) drones on this grid. Each drone starts at an initial position and must move to a corresponding target position. Every command moves all drones simultaneously by one unit in one of the four cardinal directions (up, down, left, or right). Determine the minimum number of commands required so that every drone reaches its target.
The key observation is that the number of commands required is equal to the maximum absolute difference in the x-coordinates or the y-coordinates between the initial and target positions of any drone. Formally, if a drone at \((x_i,y_i)\) needs to move to \((x'_i,y'_i)\), the answer is given by \[ \max_{1 \le i \le K} \max\left(|x_i - x'_i|, |y_i - y'_i|\right). \]
inputFormat
The first line contains three integers: \(N\), \(M\), and \(K\) — the dimensions of the grid and the number of drones.
The second line contains \(2K\) integers representing the initial positions of the drones in the format \(x_1\ y_1\ x_2\ y_2\ \ldots\ x_K\ y_K\).
The third line contains \(2K\) integers representing the target positions in the same format.
outputFormat
Output a single integer which is the minimum number of commands required to move all drones from their initial positions to their target positions.
## sample5 5 3
1 1 2 2 3 3
5 5 4 4 2 2
4
</p>