Problem J
Recycling
Heck S. Quincy (or Hex as his friends call him) is in charge of recycling efforts in the Quad Cities within the greater Tri-state area as well as the Twin Cities in the Lone Star State. One of the programs he oversees is the placement of large recycling bins at various locations in the cities. Transporting these bins is very expensive so he tries to keep them at any given location for as long as possible, emptying them once a week. He’s willing to keep a bin at a given location as long as it is full at the end of each week.
Hex has very reliable estimates of the amount of recyclable materials (in cubic meters) that he can expect each week at each location. Given this information he would like to know when to install the recycling bin of an appropriate size to maximize the amount of material recycled. He will keep the bin at that location up to (but not including) the week when they don’t expect it to be filled to capacity.
For example, suppose Hex has the following estimates for the
next seven weeks:
-
A capacity-
bin from week until week , recycling -
A capacity-
bin from week until week , recycling -
A capacity-
bin from week until week , recycling (this is the maximum possible)
Hex would not place a capacity-
Input
Input starts with a line containing a single positive
integer
Output
Output three integers
Sample Input 1 | Sample Output 1 |
---|---|
7 2 5 7 3 5 10 2 |
2 6 15 |
Sample Input 2 | Sample Output 2 |
---|---|
8 2 5 7 3 5 10 2 4 |
1 8 16 |