Solution of SPOJ problem(Fashion Shows) -http://www.spoj.com/problems/FASHION/