ColorfulDecoration
SRM 464 · 2009-11-12 · by lyrically
Problem Statement
Return the maximum possible size of the smallest of the N sheets of paper. The size of a square sheet of paper is its side length. If you cannot place all N sheets, then return 0 instead.
Notes
- It can be proved that the answer is always an integer.
Constraints
- xa will contain between 2 and 50 elements, inclusive.
- xa, ya, xb, and yb will contain the same number of elements.
- Each element of xa, ya, xb, and yb will be between 0 and 1,000,000,000, inclusive.
{ 10, 0, 7 }
{ 0, 19, 6 }
{ 20, 10, 25 }
{ 20, 35, 25 }
Returns: 19
In the picture above, the numbers represent the candidates for the center of each color. Choose (10, 0) for color 0, (0, 19) for color 1, and (25, 25) for color 2. The paper with color 2 could be larger, but the size of the smallest sheet cannot exceed 19.
{ 464, 20 }
{ 464, 10 }
{ 464, 3 }
{ 464, 16 }
Returns: 461
(xa[i], ya[i]) and (xb[i], yb[i]) might be the same.
{ 0, 0, 1, 1 }
{ 0, 0, 1, 1 }
{ 1, 1, 0, 0 }
{ 1, 1, 0, 0 }
Returns: 0
No matter how we choose to place the squares, at least two of them will have the same center. This means we cannot place four sheets of non-zero size without overlapping, so we return 0.
{ 0, 3, 0, 5, 6 }
{ 1, 6, 0, 8, 5 }
{ 6, 1, 7, 4, 7 }
{ 5, 9, 2, 8, 9 }
Returns: 3
{ 1000000000, 0 }
{ 0, 1000000000 }
{ 0, 1000000000 }
{ 0, 1000000000 }
Returns: 1000000000
Submissions are judged against all 94 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ColorfulDecoration with a public method int getMaximum(vector<int> xa, vector<int> ya, vector<int> xb, vector<int> yb) · 94 test cases · 2 s / 256 MB per case