A forest of perpendiculars

Problem Name:
A forest of perpendiculars
Site:HackerEarth
Links:
Tags:
Problem setters: