ADA University - March 7 - Segment Tree
Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the beautiful silhouettes formed by the rectangular buildings.
The entire horizon is represented by a number line with n (1 ≤ n ≤ 40000) buildings. Building i's silhouette has a base that spans locations
bi along the horizon (1 ≤
109) and has height
hi (1 ≤
109). Determine the area, in square units, of the aggregate silhouette formed by all n buildings.
First line contains a single integer n. Each of the next n lines describes building i with three space-separated integers:
Print the total area, in square units, of the silhouettes formed by all n buildings.
4 2 5 1 9 10 4 6 8 2 4 6 3