Why is this not greedy? i.e.if A has fewer coins than B, then he should get the next biggest coin. What's the flaw in this logic? I'd like to know what you think. (I got around this by a test case: 2 2 2 2 2 | 5 5 is optimal but greedy would yield 5 2 2 2 | 5 2 2).

jddantes wrote:Why is this not greedy? i.e.if A has fewer coins than B, then he should get the next biggest coin. What's the flaw in this logic? I'd like to know what you think. (I got around this by a test case: 2 2 2 2 2 | 5 5 is optimal but greedy would yield 5 2 2 2 | 5 2 2).

Try this example:
2 2 3 6

Optimal is A = 2 2 3 and B = 6
With the logic you used, you will get A = 2 3 and B = 2 6