Help needed in candies distribution!

Revision en1, by code_warrior, 2020-07-12 17:24:41

Hello,guys! I tried to solve the problem candies distribution of codeforces. But, i don't know why it is giving wrong answer on test 67. My idea is to find the highest element in each iteration (because the highest element will have no element greater then it in its left or right sides, So l[i]=r[i]=0.) and the allocate the val (initially val=n) to all such positions and subtract their contribution from every position accordingly and then do val--. Although the editorials approach is different from mine, I will be happy to know where am i wrong or my idea is not correct. This is the problem This is my code

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English code_warrior 2020-07-12 17:25:59 16
en1 English code_warrior 2020-07-12 17:24:41 765 Initial revision (published)