WA in SUMTRIAN

Hi guys can someone please help me out. I’m getting correct output for the sample input but still getting WA.
https://www.codechef.com/viewsolution/33436238
Thanks.

How did you even come up with this? There are more cases that this program will get wrong than right. Why sum - 1? How does the sorting relate to the fact that you have to go right or stay on the same column?

I tried solving some cases myself both sorted and unsorted and I noticed that answer was always 1 less than that from the sorted array. So sum-1 :confused: . Also, I’m new to this :slightly_frowning_face:

I mean… any case where all the numbers are equal

1 Like

Yeah in that case it fails. Thanks.