What is the logic of question Three is Crowd?

Plz someone help me with logic of question http://www.codechef.com/problems/CROWD. There are so many cases possible applying combination and i am not able to give it a generalised form .

@aayushi24:

have a look at the editorial : http://discuss.codechef.com/questions/2263/crowd-editorial

1 Like

thanks @squal