3376. Minimum Time to Break Locks I
Bob is stuck in a dungeon and must break
nlocks, each requiring some amount of energy to break. The required energy for each lock is stored in an array calledstrengthwherestrength[i]indicates the energy needed to break theithlock.To break a lock, Bob uses a sword with the following characteristics:
- The initial energy of the sword is 0.
- The initial factor
Xby which the energy of the sword increases is 1.- Every minute, the energy of the sword increases by the current factor
X.- To break the
ithlock, the energy of the sword must reach at leaststrength[i].- After breaking a lock, the energy of the sword resets to 0, and the factor
Xincreases by a given valueK.Your task is to determine the minimum time in minutes required for Bob to break all
nlocks and escape the dungeon.Return the minimum time required for Bob to break all
nlocks.
1 | class Solution { |