Stack and Sorting

I am not asking for solution but just wanna know if this question is correct b’coz i guess this is incorrect question as I have done the code for this question which actually passed the given test cases but still it is giving me the WA idk why … maybe i m unable to hit some edge test cases.

This is the question link https://www.codechef.com/UCSD2020/problems/DSLA6.