Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Break Locks I

med
30 min
Try to solve the Minimum Time to Break Locks I problem.

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

med
30 min
Try to solve the Minimum Time to Break Locks I problem.

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