Minimum Time for All Deliveries Given Agent Constraints

Problem You have n delivery orders at positions on a number line and k agents starting at position 0, each moving at speed 1. Find the minimum time to complete all deliveries with agents working in parallel.

Input / Output

  • Input: array orders of positions, integer k.
  • Output: the minimum time to finish all deliveries.

Constraints

  • 1 ≤ k ≤ n ≤ 10^5.
  • 1 ≤ orders[i] ≤ 10^9.

Example

  • orders=[2,5,9], k=2 → 5 (agent 1 covers [2,5], agent 2 covers [9]; max time = 5)
added …
LeaderboardSalaryAccount