#P4012. Deep Sea Specimen Collection Maximization
Deep Sea Specimen Collection Maximization
Deep Sea Specimen Collection Maximization
A submarine carrying several deep‐sea robots is about to begin a scientific expedition on the ocean floor. Once the submarine reaches the seabed, each robot will leave the submarine and move independently toward its predetermined destination.
On its way, each robot must collect marine biological specimens (each with a known value) located on the grid edges it traverses. However, each specimen can be collected only once – if more than one robot passes over an edge, only the robot that arrives there first will collect the specimen.
The robots are constrained to move only north or east. They operate on a grid, with the southwestern corner at and the northeastern corner at . A move east from to collects the specimen on the horizontal edge with value given in the input, and a move north from to collects the specimen on the vertical edge (its value also provided in the input).
You are given the grid dimensions, the values on all horizontal and vertical edges, and robots (each with a starting coordinate and a destination that satisfies and ). Determine the maximum total value of specimens that can be collected if you choose an optimal monotonic (north–or–east only) path for each robot. All formulas are in LaTeX format.
inputFormat
The input is given as follows:
1. The first line contains three integers: , , and , where and define the grid (the grid has rows and columns) and is the number of robots.
2. The next lines each contain integers. The -th line (using 0–indexing for rows) contains the values on the horizontal edges in row . An integer on this line corresponds to the edge from to for .
3. The following lines each contain integers. The -th line contains the values on the vertical edges in column . An integer on this line corresponds to the edge from to for .
4. The next lines each contain four integers: , , , , representing a robot's starting coordinate and its destination (with and ).
outputFormat
Output a single integer – the maximum total value of specimens that can be collected by the robots along their chosen monotonic paths.
sample
2 2 1
1 2
3 4
5 6
7 8
9 10
11 12
0 0 2 2
26