#P16169. [ICPC 2015 NAIPC] Sand Art

[ICPC 2015 NAIPC] Sand Art

题目描述

At art shows, it is very common to have booths where children can create their very own sand art. This art is typically made by taking a jar or bottle and filling it with layers of different colors of sand. Instead of a bottle, this year a new container is being used for decorating! The container is a glass box!

The box has a 2D rectangular face and a thickness of exactly 11 unit. Inside the glass box, n1n - 1 vertical dividers are placed to separate it into nn sections. In the example below, the box is divided into 44 sections using 33 dividers:

:::align{center} :::

Sometimes the children want certain amounts of each color to be in each section of their work of art. They specify a minimum and maximum for each combination of section and sand color. Your task is to help them find how balanced they can make the artwork. This is done by minimizing the difference between the sand heights in the section with the highest overall sand level and the section with the lowest overall sand level.

输入格式

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. Each input begins with a single line with 4 space-separated integers, nn mm ww hh, where:

  • nn (2n2002 \leq n \leq 200) is the number of sections
  • mm (1m2001 \leq m \leq 200) is the number of colors of sand
  • w,hw, h (1w,h50001 \leq w, h \leq 5000) are the width and height of the box (it always has a depth of 11)

The next line will contain mm space-separated real numbers (with at most 3 decimal places) vv (0<vwh0 < v \leq w \cdot h), which represent the volumes of each color of sand. It is not necessary to use all of the sand, but the minimums for each section must be satisfied.

The next line will have n1n - 1 space-separated real numbers (with at most 3 decimal places) xx (0<x<w0 < x < w) which represent the distance from the left wall of each divider. The xxs are guaranteed to be sorted in increasing order.

The next nn lines will each have mm space-separated real numbers (with at most 3 decimal places) minmin (0minwh0 \leq min \leq w \cdot h). The jthj^{\text{th}} element of the ithi^{\text{th}} row is the minimum amount of sand color jj to be put in section ii.

The next nn lines will each have mm space-separated real numbers (with at most 3 decimal places) maxmax (0maxwh0 \leq max \leq w \cdot h). The jthj^{\text{th}} element of the ithi^{\text{th}} row is the maximum amount of sand color jj to be put in section ii, and minijmaxijmin_{ij} \leq max_{ij}.

输出格式

Output a real number rounded to exactly 3 decimal places representing the minimum difference possible between the maximum and minimum heights of sand in the sections. A distribution of sand will always be possible that satisfies the constraints in the input.

2 2 5 5
2.0 2.0
4.0
1.0 0.0
0.0 1.0
1.0 0.0
0.0 2.0
0.750
2 2 5 5
2.0 2.0
4.0
1.0 0.0
0.0 1.0
1.5 0.0
0.0 2.0
0.625
2 5 11 10
3.0 4.0 4.0 9.0 2.0
4.0
2.0 2.0 1.0 0.5 0.25
0.0 2.0 0.0 4.0 1.0
2.0 2.0 3.0 4.0 0.75
0.0 2.1 0.0 5.1 1.1
0.266