Halley (an astronomer graduate of Oxford University) studies the sky to find as many commets as possible.Assume the sky is a flat plane. All the stars lie on it with a location (x, y)
. For each star, there is a grade ranging from 1 to 100, representing its brightness, where 100 is the brightest and 1 is the weakest. The window though which Haley observeds the sky is a rectangle whose edges are parallel to the x-axis or y-axis. Your task is to tell where Haley should put the window in order to maximize the sum of the brightness of the stars within the window. The stars which are right on the edge of the window do not count. The window can be translated but rotation is not allowed.
An input file for LP systems contains the following facts:
sky(Number,W,H)
containing the number of stars, the horizontal width and the vertical height of the rectangle-shaped window.star(Number,X,Y,B)
containing the star number, the location (X,Y)
and the brightness of each star. No two stars are on the same location. There are at least 1 and at most 10000 stars in the sky with 1 ≤ W
,H ≤ 1000000
, 0 < X
,Y < 231
.
The output should contain exactly one fact of the form solution(S)
, where S
is the maximum brightness observable through the window (i.e., the window is possitioned in such a way that maximizes the sum of the brightness of the stars within the window).
Examples:
sky(3, 5, 4).
Output:
star(1, 1, 2, 3).
star(2, 2, 3, 2).
star(3, 6, 3, 1).
solution(5).
sky(3, 5, 4).
Output:
star(1, 1, 2, 3).
star(2, 2, 3, 2).
star(2, 5, 3, 1).
solution(6).