QOJ.ac

QOJ

Límite de tiempo: 3.0 s Límite de memoria: 512 MB Puntuación total: 100

#12939. Sand Art

Estadísticas

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 1 unit. Inside the glass box, $n-1$ vertical dividers are placed to separate it into $n$ sections. In the example below, the box is divided into 4 sections using 3 dividers:

problem_12939_a791341bc28f5dcc4882afd28a8fbaa0.png

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.

Input

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, $n\ m\ w\ h$, where:

  • $n$ ($2 \le n \le 200$) is the number of sections
  • $m$ ($1 \le m \le 200$) is the number of colors of sand
  • $w,h$ ($1 \le w,h \le 5\,000$) are the width and height of the box (it always has a depth of 1)

The next line will contain $m$ space-separated real numbers (with at most 3 decimal places) $v$ ($0<v \le 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 $n-1$ space-separated real numbers with at most 3 decimal places) $x$ ($0<x<w$) which represent the distance from the left wall of each divider. The $x$s are guaranteed to be sorted in increasing order.

The next $n$ lines will each have $m$ space-separated real numbers (with at most 3 decimal places) $min$ ($0 \le min \le w\cdot h$). The $j$th element of the $i$th row is the minimum amount of sand color $j$ to be put in section $i$.

The next $n$ lines will each have $m$ space-separated real numbers (with at most 3 decimal places) $max$ ($0 \le max \le w\cdot h$). The $j$th element of the $i$th row is the maximum amount of sand color $j$ to be put in section $i$, and $min_{ij} \le max_{ij}$.

Output

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.

Examples

Input 1

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

Output 1

0.750

Input 2

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

Output 2

0.625

Input 3

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

Output 3

0.266

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.