Imagine you're the manager of a mountain demolition project where multiple workers need to completely level a mountain to height zero. Each worker has different efficiency levels and works simultaneously with others.
You are given:
mountainHeight- an integer representing the initial height of the mountainworkerTimes- an array whereworkerTimes[i]represents the base time (in seconds) for worker i
The Challenge: Each worker becomes progressively slower with each unit of height they remove. Specifically, for worker i to reduce the mountain height by x units total, they need:
workerTimes[i] × 1 + workerTimes[i] × 2 + ... + workerTimes[i] × x seconds
This equals workerTimes[i] × (1 + 2 + ... + x) = workerTimes[i] × x × (x + 1) / 2 seconds
Goal: Find the minimum number of seconds needed for all workers combined to reduce the mountain height to exactly zero.
Input & Output
Constraints
- 1 ≤ mountainHeight ≤ 105
- 1 ≤ workerTimes.length ≤ 104
- 1 ≤ workerTimes[i] ≤ 106
- All workers work simultaneously