Help with CHEFEXQ

help
bug
chefexq
error
support

#1

I have done the code according to the editorial but getting some WA but no TLE. It would be nice to get some help…

Code Link - https://www.codechef.com/viewsolution/17183054

Problem Link - https://www.codechef.com/problems/CHEFEXQ

Thank you