User:Jeff/Lots of Sunlight

Analysis
Out of the ten problems at world finals, Lots of Sunlight was solved by the most teams. It is easy to understand, and straightforward to solve with a little trigonometry.

For each apartment to query, we need to first determine if it exists in the input. Assuming that it does, we calculate the starting and ending sunlight times individually. To find the starting time, consider a point p at the bottom-west corner of the apartment. For each building to the west, connect that building's upper-east corner to the point p. Find the angle that this line makes with the horizon (using the  function), and take the largest angle out of all the buildings to the west. Do the same with the bottom-east corner of the apartment and the upper-west corner of buildings to the east, and you'll have the ending angle calculated.