#P11512. Force Field Experiment
Force Field Experiment
Force Field Experiment
In a physical biology laboratory, researchers are investigating the effect of radiation on plants by using force fields. The experimental setup includes a square platform of size \(10^9 \times 10^9\) covered with fertile soil. Above the platform, a radiation source is installed. Between the source and the platform, there are \(n\) force fields that can be activated.
The force field generator is installed at the point \((0, 0)\). The \(i\)-th force field is a rectangle whose sides are parallel to the borders of the platform, and its two opposite vertices are at \((0, 0)\) and \((x_i, y_i)\). Thus, the \(i\)-th force field covers the area of the rectangle \([0, x_i] \times [0, y_i]\).
During the experiment, the researchers plan to activate exactly \(k\) force fields from the given \(n\) fields. The effective area covered by the activated force fields is the intersection of their rectangular regions. Since all rectangles share the common vertex \((0,0)\), the intersection of any \(k\) chosen rectangles is \([0, A] \times [0, B]\), where \(A = \min\{x_i\}\) and \(B = \min\{y_i\}\) over the chosen force fields. The area of the intersection is \(A \times B\).
The goal is to select \(k\) force fields such that the intersection area \(A \times B\) is maximized, and then output that maximum area.
inputFormat
The first line contains two integers \(n\) and \(k\) (\(1 \le k \le n\)). Each of the following \(n\) lines contains two integers \(x_i\) and \(y_i\) (both positive), representing the coordinates of the opposite vertex of the \(i\)-th force field.
You can assume the platform is large enough so that all force fields lie completely inside it.
outputFormat
Output a single integer representing the maximum possible area of the intersection of the \(k\) selected force fields.
sample
3 2
3 4
5 2
4 6
12