Dynamic Programming

www.spoj.com/problems/PARTY