Comments

why cnt/2 shouldn't it be cnt — 1 as for all the v[i] B will act first and increase value by 1 except in the starting case as A has to make the first move

okk... i can see now....

understand it!! great solution

what i was doing for a particular i finding the largest value in the cnt array and if the value == i then find the max element smaller than i. this i achieved by storing 2 values in the node (largest and value smaller than it) -> and merge the nodes accordingly... but it is giving TLE on 6

-