Richard has quit competitive programming and has opened an ice cream stand. Help him run his stand! Here are the operations to support:
ADD K P - Richard is now willing to sell more ice cream cones, each at dollars.
ADDRANGE A B - Richard is now willing to sell one more ice cream cone for each price between and , inclusive.
BUYAMT Q - Nick has dollars, and buys the maximum number of cones he can,
starting from cheapest to most expensive. Report how many cones Nick buys.
BUYLOW L - Nick buys the cheapest cones Richard is selling, or all of
them if Richard is selling fewer than of them. Report the total cost of
the cones bought.
BUYHIGH L - Nick buys the most expensive cones Richard is selling, or
all of them if Richard is selling fewer than of them. Report the total
cost of the cones bought.
COST L - Report the cost of the th cheapest cone. If there are fewer than
NUMCONES - Report how many cones Richard is currently selling.
TOTALCOST - Report the total cost of every cone that Richard is currently
For 2 marks, .
For 3 additional marks, there will be no
For 4 additional marks, there will be no
The first line will contain a single positive integer , the number of operations to support. will be at most .
Each of the next lines will contain information for one of the operations, as shown above.
As written above, , , , and .
For every operation that demands reporting a value, print out the desired value.
8 ADD 5 4 ADDRANGE 1 7 BUYAMT 3 BUYLOW 2 BUYHIGH 2 COST 1 NUMCONES TOTALCOST
2 7 13 4 6 25