Chef And Plants
CodeChefOpen on judge ↗
Chef is the richest person in his town Chefinia. Chef has a big garden along with greenhouse. Garden has N plants, each with a height hi (0 ≤ i ≤ N-1). Now chef wants to trim some of the plants to make all the plants of the same height. In one move, chef can select a range L,R (0 ≤ L ≤ R ≤ N-1) and reduce the height of all plants in the range by 1. Chef is feeling lazy and wants to know what i
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