So this is the problem. And this is the official place to debug the solution on extensive test cases. I get the accepted answers on the most upvoted test case by brianfry. (Please click the second link and you will know what I am talking about).
Here is my code(it’s documented), but when I submit it to the online judge, I get a WA. Please help.
I check if the boy (prince) has both the cards higher than those of princess than the boy is sure to win with the smallest undealt card added to his hand.
Else to make the prince win he should be able to win at least one round on his own. I check for this assuming he plays the worst he could (ie he only wins when he can’t lose) whereas the princess plays the best play always (ie wins with the smallest card that is greater than that of the prince possible and if sure to lose plays her absolute smallest card).