Help Needed

Can anyone help me in the problem
https://www.codechef.com/problems/HIRINGWO
, my code is giving correct answer of test cases which I got from editorial but still it is giving WA. Please help me if you can
https://www.codechef.com/viewsolution/39849909