problem link: http://www.spoj.com/problems/PARTY/

my solution: http://ideone.com/1DbuAF

Problem is,I’m getting a different(least possible) value for the **sum of entrance** part for the same optimal solution. The problem states that **“Achieve the highest possible fun level, and do not spend more money than is absolutely necessary.”** which makes me believe that we need to calculate the minimal entrance fee and even the comments from the problem page say so. So my program calculates the minimal entrance fees and prints `36 32`

instead of `48 32`

and gets WA as expected.

I don’t understand what is actually required and where am I going wrong or how to get it correct. A little bit of clarification would be extremely helpful.

Thank you.