I have a question where there are four arrays, two for men and two for women. One of the men array is the age in increasing order and the other array is the height of men in increasing order. The two arrays for women are also the same.
Now if one of the men marries a women, then form the age array, the men to the left of this man should marry the women to the left of the lady. and the men right to this man should marry the women to the right of this lady.
Eg: if Mens ages array is {8,9,23,25,27,28,..} and womens age array is {7,9,12,20,28,...} and if the man with age 27 marries the lady with age 20, then the men with ages 8,9,23,25 should marry a lady from 7,9,12. and like wise with the right side men.
NO matter if they do not marry, but if at all they marry, that should be the case.
After marriage, they have children based on the height arrays. If the height difference between the couple is 0 then they have 7 children, if the height difference is 1-2 then they have 6 children, if the height difference is 3-4 then they have 5 children,..... like wise if the height difference is 13 or more then they have 0 children.
So i need an algorithm which can maximize the number of children.I need the maximum number of children.
It can be any language, basically i need an algorithm.