Combinatorics problem

Hello! I’m trying to solve the problem Random Teams. I’m able to figure out how the maximum number of pairs is calculated, but having trouble understanding the logic behind finding the minimum number of pairs. I went through the tutorial and this submission and I’m not able to understand the part c2*sum(v+1).
Thanks!

It is a easy problem.
I hope the case of maximum is fine.
For minimum teams,
lets say
n=12 and m=5
So,
Effectively u can distribute 2 person each to 5 team
So, left=2
No of people in each team=1
then give rest 2 people to team A and team B 1 each.

Example-> n=20 and m=6

{3 , 3 ,3 , 3, 3 , 3} //now left=20-18=2
So give 1 and 1 to starting 2 teams

Final Distribution
{4,4,3,3,3,3}
Hit like if u get it :slight_smile:

Maine ganda code likha hua h, hope kuch samaj m aa jaaye :stuck_out_tongue:
https://ide.codingblocks.com/s/60067

1 Like

Thank you so much for the explanation and sorry for my silly doubts!

1 Like