cielseven's picture
add benchmark corpora, groundtruth, symexec scripts and coverage docs
bff4ec7
|
Raw History Blame Contribute Delete
458 Bytes

Huffman Merge Cost

Description

Repeatedly merge two available weights, paying their sum each time, until one weight remains. Find the minimum possible total cost.

Input

The function receives the input weights and a writable work array.

Output

Return the minimum total merge cost.

Constraints

  • $1 \le n \le 8$.
  • $1 \le weight_i \le 1000$.

Source

Classical Huffman optimal-merge problem reconstructed from the verified C artifact.