MAXIMUM CANDIES-Can you help me in finding a test case in which my code is giving wrong answer ?!

why my code is giving WA for MAXIMUM CANDIES?
here is my code link–>Chef and candies

kindly do reply! <3

You did not handle the edge case properly:
1 1 10 5
Answer should be 10. You code outputs 5
Your AC code here


You missed the famous edge case which cost 100 p to many of us :slight_smile:
Your code will fail for this test case.

1 1 2 1
OUTPUT= 2 (Yours 1)

The sum limit Y is for adjacent elements and in this case there will be no adjacent case , so

ans = x (=2)


thanks a lot figured it out completely!!

Yeah bro figured it out thank you a lot!