本文主要是介绍POJ 3277 City Horizon /洛谷 P2061 [USACO07OPEN],希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目描述
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。
输出格式:一个数,数列中所有元素的和。
输入输出样例
4 2 5 1 9 10 4 6 8 2 4 6 3
16
说明
N<=40000 , a、b、k<=10^9 。
这篇关于POJ 3277 City Horizon /洛谷 P2061 [USACO07OPEN]的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!