Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Finish the Race

med
30 min
Try to solve the Minimum Time to Finish the Race problem.

Statement

You are given a 22D integer array tires where tires[i] = [f_i, r_i] indicates that the iith tire takes fif_i seconds to complete its first lap, and each subsequent consecutive lap completed using the same tire takes rir_i times the time of the previous lap.

Specifically, the xxth consecutive lap run on the iith tire takes fiimesri(x−1)f_i imes r_i^{(x - 1)} seconds.

You are also given an integer changeTime and an integer numLaps.

The race consists of numLaps laps. You may begin the race using any tire for free. You can change to any tire (including a brand new tire of the same type) at any time, but doing so adds changeTime seconds to your total time. There is no limit to the number of tires available of each type.

Return the minimum total time required to finish all numLaps laps.

Constraints:

  • 1≤1 \leq tires.length ≤105\leq 10^5

  • tires[i].length =2= 2

  • 1≤fi1 \leq f_i, changeTime ≤105\leq 10^5

  • 2≤ri≤1052 \leq r_i \leq 10^5

  • 1≤1 \leq numLaps ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Finish the Race

med
30 min
Try to solve the Minimum Time to Finish the Race problem.

Statement

You are given a 22D integer array tires where tires[i] = [f_i, r_i] indicates that the iith tire takes fif_i seconds to complete its first lap, and each subsequent consecutive lap completed using the same tire takes rir_i times the time of the previous lap.

Specifically, the xxth consecutive lap run on the iith tire takes fiimesri(x−1)f_i imes r_i^{(x - 1)} seconds.

You are also given an integer changeTime and an integer numLaps.

The race consists of numLaps laps. You may begin the race using any tire for free. You can change to any tire (including a brand new tire of the same type) at any time, but doing so adds changeTime seconds to your total time. There is no limit to the number of tires available of each type.

Return the minimum total time required to finish all numLaps laps.

Constraints:

  • 1≤1 \leq tires.length ≤105\leq 10^5

  • tires[i].length =2= 2

  • 1≤fi1 \leq f_i, changeTime ≤105\leq 10^5

  • 2≤ri≤1052 \leq r_i \leq 10^5

  • 1≤1 \leq numLaps ≤1000\leq 1000