Need Help with PRFXGD, WA for second subtask

link to mysolution
https://www.codechef.com/viewsolution/30848424