Problem Statement | |||||||||||||
A prefix-free code of size N which uses K characters is a set of N distinct strings such that
You are given the size of the code N and the costs of using the characters characterCosts. Return the minimal possible cost of a prefix-free code of size N which uses these character costs. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | N will be between 2 and 500, inclusive. | ||||||||||||
- | characterCosts will contain between 2 and 50 elements, inclusive. | ||||||||||||
- | Each element of characterCosts will be between 1 and 100, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|