Help in 2nd problem of lunchtime

Can anyone tell me where this solution for 2nd problem is going wrong? https://www.codechef.com/viewsolution/16374117
p.s.- Its my friend’s code and he asked me to debug it after contest but i failed too

1 Like

@soham1234. Why are you directly updating on index x%b where you have actually sorted the vector and messed up the data and the actual element may be somewhere else. I may be wrong again. Please verify.

1 Like

Could Someone Please tell me why this particular solution is giving a wrong answer for the same problem?
https://www.codechef.com/viewsolution/16374812
i tried several methods but my answer was never accepted completely.Could Someone tell me the input for which it gives the wrong answer.??
Help of any kind would be highly appreciated.

Can anyone tell me why my solution is giving wrong answer on subtask #2 but correct answer on subtasks #1 and #3. https://www.codechef.com/viewsolution/16377252

n=1e5 for a particular testcase

@soham1234 Sorry my problem. Updated answer.

@aayushkapadia Can you please explain how to solve L-R queries?

Your product in num is overflowing. Use long long.