2178. City Horizon

单点时限: 2.0 sec

内存限制: 256 MB

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 <= 40,000) buildings. Building i’s silhouette has a base that spans locations A_i through B_i along the horizon (1 <= A_i < B_i <=1,000,000,000) and has height H_i (1 <= H_i <= 1,000,000,000). Determine the area, in square units, of the aggregate silhouette formed by all N buildings.

输入格式

  • Line 1: A single integer: N

  • Lines 2..N+1: Input line i+1 describes building i with three space-separated integers: A_i, B_i, and H_i

输出格式

  • Line 1: The total area, in square units, of the silhouettes formed by all N buildings

样例

Input
4
2 5 1
9 10 4
6 8 2
4 6 3
Output
16

9 人解决,24 人已尝试。

23 份提交通过,共有 111 份提交。

7.5 EMB 奖励。

创建: 17 年,7 月前.

修改: 7 年,3 月前.

最后提交: 1 年,5 月前.

来源: Elite 2007 US Open Competition

题目标签