Submit | All submissions | Best solutions | Back to list |
XIXO - brownie |
Bessie has baked a rectangular brownie that can be thought of as an R×C grid (1 <= R <= 500; 1 <= C <= 500) of little brownie squares. The square at row i, column j contains N_ij (0 <= N_ij <= 4,000) chocolate chips.
Bessie wants to partition the brownie up into A*B chunks (1 <= A <= R; 1 <= B <= C): one for each of the A*B cows. The brownie is cut by first making A-1 horizontal cuts (always along integer coordinates) to divide the brownie into A strips. Then cut each strip *independently* with B-1 vertical cuts, also on integer boundaries. The other A*B-1 cows then each choose a brownie piece, leaving the last chunk for Bessie. Being greedy, they leave Bessie the brownie that has the least number of chocolate chips on it.
Determine the maximum number of chocolate chips Bessie can receive, assuming she cuts the brownies optimally.
As an example, consider a 5 row × 4 column brownie with chips distributed like this:
1 2 2 1 3 1 1 1 2 0 1 3 1 1 1 1 1 1 1 1
Bessie must partition the brownie into 4 horizontal strips, each with two pieces. Bessie can cut the brownie like this:
1 2 | 2 1 --------- 3 | 1 1 1 --------- 2 0 1 | 3 --------- 1 1 | 1 1 1 1 | 1 1
Thus, when the other greedy cows take their brownie piece, Bessie still gets 3 chocolate chips.
Input
- Line 1: Four space-separated integers: R, C, A, and B.
- Lines 2 to R+1: Line i+1 contains C space-separated integers: Ni,1 ... Ni,c.
Output
A single integer giving the required answer.
Example
Input: 5 4 4 2 1 2 2 1 3 1 1 1 2 0 1 3 1 1 1 1 1 1 1 1 Output: 3
Problem was added from USACO.
Added by: | Nikoloz Svanidze |
Date: | 2011-05-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 BASH C99 |
Resource: | ... |
hide comments
2011-07-26 18:15:24 Luka Hrabar
* Line 1: Four space-separated integers: R, C, A, and B * Lines 2..R+1: Line i+1 contains C space-separated integers: N_i1, ..., N_iC Last edit: 2011-07-26 18:15:49 |
|
2011-06-19 16:58:16 lazzyboyy
where the hell is input for 'a' and 'b' how many.. chunks we need???? |
|
2011-05-27 08:13:18 Siarhei Kulik
Please rejudge. Last edit: 2011-05-29 06:31:14 |