This is the question: https://www.codechef.com/problems/MINEAT
This is my solution - https://www.codechef.com/viewsolution/18905480
My solution gives correct answer for sample test cases. I know this solution will not get me through Subtask2 but I think it should have cleared Subtask1. Please help.