#P7164. [COCI 2020/2021 #1] 3D Histogram
[COCI 2020/2021 #1] 3D Histogram
Description
In a 3D histogram, we place 3D blocks. Each block has width . Viewed from the front, they form a 2D histogram whose heights from left to right are . Viewed from the top, they form a 2D histogram whose heights from left to right are .
Find the volume of the largest rectangular cuboid that can be placed inside the histogram. All edges of the cuboid must be parallel to the width, length, and height of the 3D blocks.
Input Format
The first line contains an integer , representing the number of 3D blocks.
The next lines each contain two integers , as described above.
Output Format
Output one integer, the maximum volume of a rectangular cuboid that can be placed.
5
5 3
4 4
2 1
3 2
1 5
24
6
3 1
2 1
2 2
2 3
1 1
2 2
8
5
15 19
5 6
1 13
3 7
1 2
285
Hint
Explanation for Sample 1
The histogram described is shown in the figure below:

The maximum cuboid volume that can be placed is .
Constraints and Notes
This problem uses bundled testdata.
- Subtask 1 (20 pts): .
- Subtask 2 (90 pts): .
For of the testdata, .
The full score of this problem is points.
Note
Translated from Croatian Open Competition in Informatics 2020 ~ 2021 Round 1 C 3D Histogram。
Translated by ChatGPT 5
京公网安备 11011102002149号