2888 - Child Play

Problems from South America regional contest

Moderator: Board moderators

2888 - Child Play

Postby andmej » Thu Aug 21, 2008 10:09 pm

I think this problem can be solved using dynamic programming (DP). I have built a table dp, where dp[i][j] is explained as follows:

Using slabs [0..i], I can organize them in such a way that the sum of the upper sides is a, and the sum of the lower sides is b. Now let the difference between a and b equal j, that is, abs(a - b) == j, then dp[i][j] == max(a, b) or -infinity if it's impossible to form 2 groups of difference j using first i slabs.

This approach let's me find out if I can form a difference of 0 using all slabs, and hence I have the answer when you should not discard any slabs.

But I don't know how to tell if discarding exactly one slab would let me form the groups to have a difference of 0.

Any help is appreciated.
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.

Are you dreaming right now?
http://www.dreamviews.com
User avatar
andmej
New poster
 
Posts: 8
Joined: Sun Feb 04, 2007 6:45 pm
Location: Medellin, Colombia

Return to South America

Who is online

Users browsing this forum: m51g8y6z4u and 1 guest

cron