开发者

Algorithm needed in any language - Related to Arrays

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 chi开发者_JAVA技巧ldren, 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.


This sounds like a problem in Discrete Optimization .

Ideally, whoever gave you this assignment shouldn't have dropped it on you without first giving you some theory on how to do this kind of stuff. But if your teacher wants to see you solve problems like this out of the blue, this keyword and link may help get you started.

I'd also recommend telling us which programming language, if any, you are fluent in. The folks here on SO (together) know most programming languages and can make suggestions tailored to be most understandable to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜