Chef and his Books
CodeChefOpen on judge ↗
Chef is an avid reader of various books. He has N books from B1 to Bn. Each book Bi has an author number Ai and happiness factor Hi. Reading book Bi gives Chef happiness P * Hi, where P is the number of authors whose books Chef read before (including the current book). Chef plans to read all books he has. Find the maximum amount of happiness he can gain by reading all books. Input - First line
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