ACM ICPC World Finals 2008

Problem J: The Sky is the Limit

This problem can be solved as follows: for each upper edge of a mountain, find all intervals of this edge for which there is an upper edge of another mountain directly above it. What remains after all these intervals have been removed, is the contribution of this particular upper edge to the Banff skyline. Extra care needs to be taken when two upper edges overlap, since you only want to count one of the two overlapping parts as contributing to the skyline.