Random Team Can any one please help me to find how minimum number of pair friends can be formed in this probem,i got the maximum part ,but not getting how to calculate minimum numbers of pairs of friends.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Random Team Can any one please help me to find how minimum number of pair friends can be formed in this probem,i got the maximum part ,but not getting how to calculate minimum numbers of pairs of friends.
Name |
---|
If there are x guys in a team, this team will produce friends, so that means the number of friends we will have in the end will be
where xi is the number of guys in team i. If there's only one possible team (m = 1), we can't do nothing, so let's assume we have m > 1
Let's see what happens when we change one guy of his team (for instance, from team x2 to team x1. All terms will be equal except those of team 1 and 2, and it's gonna be better trade if our sum diminishes:
x2 > x1 + 1
this means we should take a guy from group 2 and put him in group 1 only if the number of guys in group 2 had at least 2 guys more than group 1. Based on that, we should try to keep the size of the groups as close as possible to minimize that sum.
for minimum number you would like to have equal number of people in all groups.so first you give n/m members to each team.now you will be left with n%m members.still what is the best way to ensure equality? you distribute these n%m members 1 per team in each of the arbitrarily selected n%m team . now why did we split in such a manner to ensure equality? we found that the number of friends is proportional to square of the number of people in a team. an intuitive example if we were to find to split 100 onto two parts such that the sum of squares is minimum we would split it in 50-50. ps- i recently did this question therefore got encouraged to share my approach . no disrespect to ivanilos sir :)
Thanks for the answers