A - 3 Partition
CodeChefOpen on judge ↗
You are given $3 \cdot N$ numbers $A_1, A_2, \ldots, A_{3N}$ ($1 \le A_i \le 3$). You need to partition these $3N$ integers into $N$ triplets, each of size $3$. Each of the triplets must have the same sum. Formally, let $B_i = [C_{(i, 1)}, C_{(i, 2)}, C_{(i, 3)}]$ be the $i$-th triplet, then $C_{(i, 1)} + C_{(i, 2)} + C_{(i, 3)} = C_{(j, 1)} + C_{(j, 2)} + C_{(j, 3)}$ for all $1 \le i, j \le N$
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