WA in "Ordering the Soldiers" (ORDERS)

Problem : ORDERS Problem - CodeChef

My solution : CodeChef: Practical coding for everyone