Logo
(追記) (追記ここまで)

6242번 - City Horizon 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB224867146.711%

문제

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

제한

예제 입력 1

4
2 5 1
9 10 4
6 8 2
4 6 3

예제 출력 1

16

힌트

The first building overlaps with the fourth building for an area of 1 square unit, so the total area is just 3*1 + 1*4 + 2*2 + 2*3 - 1 = 16.

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO US Open 2007 Contest > Silver 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /