Incorrect answer for vacation problem in Atcoder

Please tell why the value of act is not retained

@tushaartiwari1997,
Why are you using greedy, I think it’s pretty clear it’s a dp problem?

Ok but can you tell why the value of act is not updating

@tushaartiwari1997,
That may be because of your if condition, try dry run on a paper and pen.

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.