Hello, in this problem 1011 — Marriage Ceremoniesthe priority index is not clear to me. I used bottom up manner and calculate the max adjacent values.
5
5 10 10 2 3
2 11 3 10 10
16 12 1 5 2
4 2 11 5 2
1 8 14 4 13
Ans:60.Which for me 14 11 12 11 10
total 58
.What am I missing here? Need help with that.
My code
Auto comment: topic has been updated by Loser_ (previous revision, new revision, compare).
I think you are missing this line=> "Remember that
each man
should be paired witha
woman and onlymonogamous
families should be formed.".If you take 14(5th man with 3rd woman) then you cannot take 11(4th man with 3rd woman).
The correct pairs will be like the following =>
10(1st man with 2nd woman), 10(2nd man with 4th woman), 16(3rd man with 1st woman), 11(4th man with 3rd woman), and 13(5th man with 5th woman).
Oh,thank you so much. I didn't get the problem statement.Will you discuss the approach here?
I didn't solve it yet and don't know how to solve it.
This problem is based on basic bitmasking. This video has exact similar problem explained so this might be helpful for others.Perhaps someone needs the solution is here also find another interesting solution for this problem is here