← All problemsSign in

Birthday Gifts

CodeChefRating 1613Open on judge ↗

It’s Chef's birthday. He and his twin have received $N$ gifts in total. The $i$-th gift has a price of $A_i$. Each twin wants to keep the most expensive gifts for himself. The twins take $K$ turns alternately (each has $K$ turns, for $2\cdot K$ turns in total). It is given that $2\cdot K+1 \leq N$. In a turn, a person may choose one gift. The only exception is the last turn of the twin who mov

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start