Couldn’t find out the reason for WA on SPOJ ? ? ! … though it’s a easy question … but getting WA … Don’t know which case i m missing … My Code : : http://ideone.com/m7N8OF
Hi! There’s a slight error in your logic. It doesn’t minimize the total number of pizzas. In fact it is wrong for the test case you provided at ideone.
5
1/2
3/4
1/2
1/4
1/4
Your answer is 4 but the correct answer is 3 (1 pizza for 3/4, 1 pizza for (1/2 + 1/4 +1/4), 1 pizza for 1/2).