当前位置: 代码迷 >> 综合 >> POJ 3277 City Horizon /洛谷 P2061 [USACO07OPEN]
  详细解决方案

POJ 3277 City Horizon /洛谷 P2061 [USACO07OPEN]

热度:32   发布时间:2024-01-15 08:12:00.0

题目描述

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 Ai through Bi along the horizon (1 ≤ Ai < Bi ≤ 1,000,000,000) and has height Hi (1 ≤ Hi ≤ 1,000,000,000). Determine the area, in square units, of the aggregate silhouette formed by all N buildings.

有一个数列,初始值均为0,他进行N次操作,每次将数列[ai,bi)这个区间中所有比Hi小的数改为Hi,他想知道N次操作后数列中所有元素的和。

输入输出格式

输入格式:

第一行一个整数N,然后有N行,每行三个正整数ai、bi、Hi。

输出格式:

一个数,数列中所有元素的和。

输入输出样例

输入样例#1:  复制
4
2 5 1
9 10 4
6 8 2
4 6 3
输出样例#1:  复制
16





说明

N<=40000 , a、b、k<=10^9 。

  相关解决方案