it probably is.
im guessing you also have to work backwords.
eg, only pirate #499 and #500 alive. then #499 can take all the gold. in a sense, #500 is worth 0, #499 is worth 100
now include pirate #498. have to give pirate #500 1gold, and retain the other 99 for himself. #498 worth 99...