Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Divide Array Into Subarrays

Try to solve the Minimum Cost to Divide Array Into Subarrays problem.

Statement

You are given two integer arrays nums and cost of equal length, and an integer k.

You need to partition the array nums into one or more non-empty contiguous subarrays.

Suppose the array is divided into mm subarrays. For the jextthj^{ ext{th}} subarray (where 1≤j≤m1 \leq j \leq m) ending at index iji_j and starting after the end of the previous subarray:
The cost of this jextthj^{ ext{th}} subarray is calculated as:
(∑t=0ijext‘nums‘[t]+ext‘k‘imesj)imes(extsumof‘cost‘inthejextthextsubarray)(\sum_{t=0}^{i_j} ext{`nums`}[t] + ext{`k`} imes j) imes ( ext{sum of `cost` in the } j^{ ext{th}} ext{ subarray})

Return the minimum total cost to divide the array into subarrays.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • cost.length ==== nums.length

  • 1≤1 \leq nums[i], cost[i] ≤1000\leq 1000

  • 1≤1 \leq k ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Divide Array Into Subarrays

Try to solve the Minimum Cost to Divide Array Into Subarrays problem.

Statement

You are given two integer arrays nums and cost of equal length, and an integer k.

You need to partition the array nums into one or more non-empty contiguous subarrays.

Suppose the array is divided into mm subarrays. For the jextthj^{ ext{th}} subarray (where 1≤j≤m1 \leq j \leq m) ending at index iji_j and starting after the end of the previous subarray:
The cost of this jextthj^{ ext{th}} subarray is calculated as:
(∑t=0ijext‘nums‘[t]+ext‘k‘imesj)imes(extsumof‘cost‘inthejextthextsubarray)(\sum_{t=0}^{i_j} ext{`nums`}[t] + ext{`k`} imes j) imes ( ext{sum of `cost` in the } j^{ ext{th}} ext{ subarray})

Return the minimum total cost to divide the array into subarrays.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • cost.length ==== nums.length

  • 1≤1 \leq nums[i], cost[i] ≤1000\leq 1000

  • 1≤1 \leq k ≤1000\leq 1000