Codeforces contest doubt

My code-


The problem link-https://codeforces.com/contest/1486/problem/A

In this my code ran successfully on all the test cases given but codeforces showed wrong ans on pretest 2
.Plz tell me why this happen and can you plz modify my codei that case

You cannot sort the given array. Hint: You can try to do it greedily.

Even if i dont sort it ,its giving the same error.
I chnged my code


please have a look at it and edit it

I don’t understand your logic. Please explain it.

if theres are more than one zeros in the array then ans is No
Also if if all the elemnts in the array is same and the no of elements is even ,then we cannot convert the array to increasing array so ans is no.
Apart from these 2 situations we can adjust the elements present and make it increaing one

Where are you getting the even situation from? And zeroes one is wrong too.

4 0 0 has yes as answer.
You can convert it into something like 0 1 3.
2 2 2 2 can be converted to 0 1 2 5.

I think you have misinterpreted the question. You can transfer from block i to i+1 any number of times.
So for every prefix i, you need to check if there are atleast (i*(i-1))/2 blocks present or not, where i goes from 1 to n.
This is because for any i, you try to form a sequence like 0,1,2,…i-1.

Thank u.I have understood my mistake

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.