TLE in CHEFCK using SLIDING WINDOW METHOD

In the MAY Challenge problem CHEFCK I tried to use Sliding Window method without using the inbuilt Double ended Queue Data Structure but it timed out, Please help me where i am slow. My code->
www.codechef.com/viewsolution/7029861

//