BOOKWRITER
CodeChefOpen on judge ↗
Sam wants to write a book but he is not a good writer. So, he finds $K$ writers who can read his mind and write his ideas into a book. Sam wants to buy pens for these $K$ writers. Sam knows that the writers will start fighting if any one among them has more number of pens than any of the other writers. So, he goes to a street which has $N$ shops to buy pens. The $i$-th shop has $a_i$ number of pe
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