opt

Time limit: 0.2s Memory limit: 64MB Input: Output:

Buzdi accidentally arrived in the future, in the year 2040, during the Informatics Olympiad for the 8th grade. He managed to remember the problem statement and wants to propose this problem earlier than planned.

Task

Consider a coordinate system xOyxOy and NN points in the plane with natural number coordinates. We call a consecutive polygon a polygon formed by two consecutive points and their projections on the OxOx axis. The total area is equal to the sum of all areas of the consecutive polygons.

An Upgrade operation is defined as incrementing the YY coordinate of a point by 1. This operation can be:

  • Used a maximum of KK times in total.
  • Used a maximum of BiB_i times for point i (1iN)i \ (1 \leq i \leq N).

Given the NN points, KK, and the vector BB, determine the maximum total area that can be obtained after applying up to KK Upgrade operations.

Input Data

The first line contains the natural numbers NN and KK separated by a space. The next NN lines contain two natural numbers XiX_i and YiY_i, separated by a space, representing the coordinates of the point on line ii. The last line contains NN natural numbers, separated by a space, representing the elements of the vector BB, as described in the problem statement.

Output Data

The output will contain a single real number with one decimal place, representing the maximum total area that can be obtained after applying up to KK Upgrade operations.

Constraints and Clarifications

  • 2N100,0002 \leq N \leq 100,000
  • 0K100,000,0000 \leq K \leq 100,000,000
  • 0Xi,Yi100,000,0000 \leq X_i, Y_i \leq 100,000,000, for 1iN1 \leq i \leq N
  • Xi<Xi+1X_i < X_{i+1}, for 1i<N1 \leq i < N
  • 0Bi100,000,0000 \leq B_i \leq 100,000,000, for 1iN1 \leq i \leq N
  • B1+B2+...+BN100,000,000B_1 + B_2 + ... + B_N \leq 100,000,000
  • A segment is considered a polygon with an area of 0.
  • For 17 points, K=0K = 0
  • For 22 points, 2N1,0002 \leq N \leq 1,000 and 1K1,0001 \leq K \leq 1,000

Example

stdin

5 2
2 0
5 1
7 2
9 2
12 1
1 2 0 1 2

stdout

18.0

Explanation

The blue points represent the points from the input data, and the dotted line represents the projection of the respective point. The first consecutive polygon is formed by the first point (2,0)(2, 0) and the second point (5,1)(5, 1) together with their projections on OxOx. The second consecutive polygon is formed by the second point (5,1)(5, 1) and the third point (7,2)(7, 2) together with their projections on OxOx and so on. We can apply the Upgrade operation to the second point and the fourth point, because B2B_2 and B4B_4 are not equal to 0. These points will now be (5,2)(5, 2) and (9,3)(9, 3), and B2=1B_2 = 1 and B4=0B_4 = 0. The total area is equal to A1+A2+A3+A4+A5=3+4+5+6=18A_1 + A_2 + A_3 + A_4 + A_5 = 3 + 4 + 5 + 6 = 18 (AiA_i represents the area of the consecutive polygon number ii). This area is the maximum possible.

Log in or sign up to be able to send submissions!