Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Set Cooking Time

Try to solve the Minimum Cost to Set Cooking Time problem.

Statement

A microwave has a keypad with digits from 00 to 99 and a 44 digit display showing time in the format mm:ss, representing minutes and seconds. The displayed time can be set by typing a sequence of 11 to 44 digits.

When a sequence of digits is entered:

  • The entered sequence represents the number of minutes and seconds, where the last 22 digits correspond to the seconds and any preceding digits correspond to the minutes.

  • Entering fewer than 44 digits is valid. For instance, entering 33 digits d1, d2, d3 is interpreted as 0d1:d2d3 (d1d_1 minutes and d2d3d_2d_3 seconds).

  • The total cooking time in seconds is calculated as $ ext{minutes} imes 60 + ext{seconds}$.

  • Both minutes and seconds can range from 00 to 9999.

You are given four integers: startAt, moveCost, pushCost, and targetSeconds.

Initially, your finger is positioned over the digit startAt.

  • Moving your finger from the current digit to a different digit costs moveCost. Moving to the same digit costs 00.

  • Pressing the button under your finger costs pushCost.

Return the minimum cost to set the microwave to cook for exactly targetSeconds seconds.

Constraints:

  • 0≤0 \leq startAt ≤9\leq 9

  • 1≤1 \leq moveCost, pushCost ≤105\leq 10^5

  • 1≤1 \leq targetSeconds ≤6039\leq 6039

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Set Cooking Time

Try to solve the Minimum Cost to Set Cooking Time problem.

Statement

A microwave has a keypad with digits from 00 to 99 and a 44 digit display showing time in the format mm:ss, representing minutes and seconds. The displayed time can be set by typing a sequence of 11 to 44 digits.

When a sequence of digits is entered:

  • The entered sequence represents the number of minutes and seconds, where the last 22 digits correspond to the seconds and any preceding digits correspond to the minutes.

  • Entering fewer than 44 digits is valid. For instance, entering 33 digits d1, d2, d3 is interpreted as 0d1:d2d3 (d1d_1 minutes and d2d3d_2d_3 seconds).

  • The total cooking time in seconds is calculated as $ ext{minutes} imes 60 + ext{seconds}$.

  • Both minutes and seconds can range from 00 to 9999.

You are given four integers: startAt, moveCost, pushCost, and targetSeconds.

Initially, your finger is positioned over the digit startAt.

  • Moving your finger from the current digit to a different digit costs moveCost. Moving to the same digit costs 00.

  • Pressing the button under your finger costs pushCost.

Return the minimum cost to set the microwave to cook for exactly targetSeconds seconds.

Constraints:

  • 0≤0 \leq startAt ≤9\leq 9

  • 1≤1 \leq moveCost, pushCost ≤105\leq 10^5

  • 1≤1 \leq targetSeconds ≤6039\leq 6039