Why partially correct?

https://www.codechef.com/viewsolution/38238936

@shiva_yanala12 Hey there , you should not start new thread related to problems asked in contest as you can post doubt related to it by putting you query in comments of editorial related to that problem . To find editorial related to problem you can scroll down your question page and field below expected output , will be having an attribute named editorial just click on link provided there.

Well in your submitted solution you are optimally trying to make each element 0 , but your logic doesn’t fits there well but if you simply see that there is no restriction on how many time you apply operations so if array consist of non negative number N then it can be made zero by subtracting N 1’s from it.

If array has negative element in it then we can’t make it 0 by applying subtraction operation on it.

So all you have to check now is does array has any negative element , if it has then answer is “NO” , else it will be “YES” .

2 Likes

thanks @pst

1 Like