Combinatorics Is Fun
Consider a multiset $S$ and a positive integer $X$. Suppose we partition $S$ into $L$ non-empty subsets such that each element of $S$ is present in **exactly one** subset. The cost of such partition is $\sum_{i=1}^L X +$ `max`$_i - $ `min`$_i$, where `max`$_i$ and `min`$_i$ denote the maximum and minimum elements of the $i-$th subset respectively. Let $F(S, X)$ denote the minimum cost required
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start