Help in atcoders candies

how to solve this?

2 Likes

This was a nice problem, see errichtos stream for the explanation.

why wrong ans

when subtracting do ans=(ans-x+MOD)%MOD
Probably this is the mistake.

2 Likes

It worked.
Ty

Hey can you help me in this . i am getting wa in 3 test cases.

Here is my solution