Tap here to switch tabs
Problem
Submissions

Problem: Find Minimum Log Transportation Cost

Try to solve the Find Minimum Log Transportation Cost problem.

Statement

You are given three integers n, m, and k, representing the lengths of two logs and the maximum log length that a truck can transport.

Each truck can carry at most one log of length at most k. If a log has a length strictly greater than k, it must be cut into smaller pieces such that every resulting piece has a length of at most k.

Dividing a log of length LL into two logs of lengths aa and bb (where a+b=La + b = L) incurs a cost of aimesba imes b.

Return the minimum total cost to cut the logs so that all pieces can be transported.

Constraints:

  • 2≤2 \leq k ≤105\leq 10^5

  • 1≤1 \leq n, m ≤2imes\leq 2 imes k

  • The input is generated such that it is always possible to transport the logs.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Minimum Log Transportation Cost

Try to solve the Find Minimum Log Transportation Cost problem.

Statement

You are given three integers n, m, and k, representing the lengths of two logs and the maximum log length that a truck can transport.

Each truck can carry at most one log of length at most k. If a log has a length strictly greater than k, it must be cut into smaller pieces such that every resulting piece has a length of at most k.

Dividing a log of length LL into two logs of lengths aa and bb (where a+b=La + b = L) incurs a cost of aimesba imes b.

Return the minimum total cost to cut the logs so that all pieces can be transported.

Constraints:

  • 2≤2 \leq k ≤105\leq 10^5

  • 1≤1 \leq n, m ≤2imes\leq 2 imes k

  • The input is generated such that it is always possible to transport the logs.