Rent Problem from SPOJ