Find the smallest array
You are given two integers $a$ and $b$. The *score* of an array $A$ of length $N$, denoted $S(A)$, is defined to be $$ S(A) = a\cdot \left(\sum_{i=1}^N \sum_{j=i+1}^N |A_i - A_j|\right) + b\cdot \sum_{i=1}^N A_i $$ You are also given an integer $K$. Find the minimum possible length of a non-empty array $A$ for which $S(A) = K$, or decide that no such array exists. If a valid array exists, y
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