When trying to work out the logic for a solution to this problem, I could not see how the example with K = 2, N = 5, M = 5 has an answer of 2.
Working backwards, when person 5 is the only 1 left, he obviously gives himself all the money. So he will reject every other proposed plan, as none are better than this.
When only 4 and 5 are left, both need to accept the proposed plan for it to be accepted. 5 will reject the solution whatever, so even if 4 offers himself 0 and 5 all the money, 4 will still be thrown off the roof.
When 3, 4 and 5 are left, 3 knows that 4 will accept anything, even 0, to avoid being thrown off the roof next time, while 5 will reject the proposed plan anyway. So 3 can give all the money to himself. 3 will reject every other proposed plan, as none are better than this.
When 2, 3, 4, 5 are left, at least 3 of them need to accept the solution. As 3 and 5 will reject everything, he cannot win, so will be thrown off the roof.
When all 5 are there, at least 3 of them need to accept the solution. As 3 and 5 will reject everything, he needs to offer a proposed plan acceptable to the others. He can offer 0 to 2 and 1 to 4, better than they receive under other plans, and keep the remaining 4 dollars for himself.
Can anyone please explain what is wrong with this argument, and why the answer is 2 not 4?