i don’t see any problems but u can try to declare vector globally and when ur subtracting getting prefix sum it might get negative so u can do prexifixr-prefixl+mod then take mod
bro u need to know how mod works suppose we have mod 26 then if prefix sum increase than 26 we take modulus the ur finding sum of range so it means ur l might be bigger than r so this is causing r-l is becoming negative
I think you haven’t done that prefix sum optimization properly. Try to first write some recursive solution with O(k * n ^ 2) complexity and then go for the iterative version with the prefix optimization O(n * k) complexity. You can have a look at my solution it has both ways mentioned - Submission #17313827 - Educational DP Contest