Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Break Locks I

Minimum Time to Break Locks I asks you to order locks in a strength array. Energy builds at the multiplier until each lock breaks, then resets as the multiplier grows. Find the least total time.

Statement

You are given an array of integers strength of length n, representing the strengths of n locks, and an integer k.

You start with an initial energy of 00 and a multiplier factor X=1X = 1. In each minute, your energy increases by XX.

To break a lock with strength strength[i], your current accumulated energy must be greater than or equal to strength[i]. Once a lock is broken:

  • Your energy resets to 00.

  • The multiplier factor XX increases by k (that is, XX becomes X+X + k).

You may break the locks in any order. The time in minutes required to break a lock of strength SS with a current multiplier XX is ⌈S/X⌉\lceil S / X \rceil.

Return the minimum total time in minutes required to break all n locks.

Constraints:

  • n == strength.length

  • 1≤n≤81 \leq n \leq 8

  • 1≤1 \leq k ≤10\leq 10

  • 1≤1 \leq strength[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Break Locks I

Minimum Time to Break Locks I asks you to order locks in a strength array. Energy builds at the multiplier until each lock breaks, then resets as the multiplier grows. Find the least total time.

Statement

You are given an array of integers strength of length n, representing the strengths of n locks, and an integer k.

You start with an initial energy of 00 and a multiplier factor X=1X = 1. In each minute, your energy increases by XX.

To break a lock with strength strength[i], your current accumulated energy must be greater than or equal to strength[i]. Once a lock is broken:

  • Your energy resets to 00.

  • The multiplier factor XX increases by k (that is, XX becomes X+X + k).

You may break the locks in any order. The time in minutes required to break a lock of strength SS with a current multiplier XX is ⌈S/X⌉\lceil S / X \rceil.

Return the minimum total time in minutes required to break all n locks.

Constraints:

  • n == strength.length

  • 1≤n≤81 \leq n \leq 8

  • 1≤1 \leq k ≤10\leq 10

  • 1≤1 \leq strength[i] ≤106\leq 10^6