Land area
Time: 1 s · Memory: 256 MB
- Prefix sums
Statement
A city is divided into cells, and the price of every cell is known. You have money. Buy a rectangular plot of maximum area (number of cells) whose total price does not exceed . If there are several such plots, choose the cheapest.
Input format
The first line contains , , (, ). Each of the next lines contains integers — the cell prices ().
Output format
A single line with two numbers: the area of the plot and its price. If no cell can be bought, print 0 0.
Examples
Input
3 5 9 1 2 3 4 5 6 7 8 9 10 5 1 1 1 1
Output
5 9
Note
Choose the top and bottom rows ( pairs) — the price of every column over these rows comes from column prefix sums in . Prices are non-negative, so two pointers work over the columns: for every right border find the leftmost border with sum . In total .
