Difficulty in problem SLAB

Can someone tell me what is wrong in my code as it gives right answer on sample input but WA on submission.
problem link-https://www.codechef.com/problems/SLAB
my code-https://www.codechef.com/viewsolution/36088690