Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost for Cutting Cake II

Try to solve the Minimum Cost for Cutting Cake II problem.

Statement

You are given an mimesnm imes n cake and two integer arrays horizontalCut of size m−1m - 1 and verticalCut of size n−1n - 1, where:

  • horizontalCut[i] represents the cost to make a cut along horizontal line ii.

  • verticalCut[j] represents the cost to make a cut along vertical line jj.

In one operation, you can slice an existing piece of cake along a horizontal or vertical line into two pieces. The cost of the operation is the cost associated with that cut line.

Return the minimum total cost required to cut the entire cake into 1imes11 imes 1 pieces.

Constraints:

  • 1≤m,n≤1051 \leq m, n \leq 10^5

  • horizontalCut.length =m−1= m - 1

  • verticalCut.length =n−1= n - 1

  • 1≤1 \leq horizontalCut[i], verticalCut[i] ≤103\leq 10^3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost for Cutting Cake II

Try to solve the Minimum Cost for Cutting Cake II problem.

Statement

You are given an mimesnm imes n cake and two integer arrays horizontalCut of size m−1m - 1 and verticalCut of size n−1n - 1, where:

  • horizontalCut[i] represents the cost to make a cut along horizontal line ii.

  • verticalCut[j] represents the cost to make a cut along vertical line jj.

In one operation, you can slice an existing piece of cake along a horizontal or vertical line into two pieces. The cost of the operation is the cost associated with that cut line.

Return the minimum total cost required to cut the entire cake into 1imes11 imes 1 pieces.

Constraints:

  • 1≤m,n≤1051 \leq m, n \leq 10^5

  • horizontalCut.length =m−1= m - 1

  • verticalCut.length =n−1= n - 1

  • 1≤1 \leq horizontalCut[i], verticalCut[i] ≤103\leq 10^3