There are several robots and factories located on the robot, where robot[i] represents the position of the factory, where factory[j] = [position, limit] indicates that the
Each robot must be assigned to a factory for repair such that no factory repairs more robots than its capacity limit. The distance a robot travels is the absolute difference between its initial position and the position of its assigned factory.
Return the minimum total distance traveled by all robots to repair every robot.
Note: The input is generated such that it is always possible to repair every robot.
Constraints:
robot.length, factory.length
factory[j].length
robot[i], $ ext{position}_j \leq 10^9$
robot.length
The input will be generated such that it is always possible to repair every robot.
There are several robots and factories located on the robot, where robot[i] represents the position of the factory, where factory[j] = [position, limit] indicates that the
Each robot must be assigned to a factory for repair such that no factory repairs more robots than its capacity limit. The distance a robot travels is the absolute difference between its initial position and the position of its assigned factory.
Return the minimum total distance traveled by all robots to repair every robot.
Note: The input is generated such that it is always possible to repair every robot.
Constraints:
robot.length, factory.length
factory[j].length
robot[i], $ ext{position}_j \leq 10^9$
robot.length
The input will be generated such that it is always possible to repair every robot.