Help needed in candies distribution!

Правка en2, от code_warrior, 2020-07-12 17:25:59

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

My code

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский code_warrior 2020-07-12 17:25:59 16
en1 Английский code_warrior 2020-07-12 17:24:41 765 Initial revision (published)