Problem 4: Architecture
https://open.kattis.com/problems/architecture
Let be the maximum of (the second line of input), and let be the maximum of (the third line of input).
If , we can always assign building heights. For example, consider the input:
4 4
3 2 4 2
1 4 1 1
Here, . Then, we can always use the row and column of and for the skylines, and fill the rest of the table with 0s:
If , there must still be an entry in the table with value , so that the eastern skyline can have in one row. Then, the column with that entry will have to have a skyline of height too, but as the maximum northern skyline height is less than, this is impossible. Similarly, is also impossible.
So, output possible
if , and output impossible
otherwise.
C++ has a function max_element()
which finds the max number in a vector. Example usage:
vector<int> v = {3, 1, 4, 7, 2};
int m = *max_element(v.begin(), v.end()); // m will be 7
Last updated