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

25804번 - Caterpillar Walk 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB27231684.211%

문제

Consider a city where each building is a rectangle with its base on the positive x-axis, its two walls parallel to the positive y-axis, and its roof parallel to x-axis. The walls of two buildings can touch each other, i.e., the buildings can be right next to each other. The buildings do not, however, have any area in common, i.e., no two buildings intersect/overlap.

Lulu (our beloved caterpillar) lives at coordinates (0,0) and works at coordinates (100,0). Every morning, Lulu crawls from home to office. Without any buildings, this is a distance of 100 but, unfortunately, the buildings force Lulu to crawl up and down of the building walls and they add to the distance Lulu has to travel. Note that Lulu starts at home, ends at the office, and is always crawling on x-axis, side of a wall going up (parallel to y-axis), top of a building (parallel to x-axis), or side of a wall coming down (parallel to y-axis).

Given the description of all the buildings, compute the total distance travelled by Lulu.

입력

The first input line contains an integer, n (1 ≤ n ≤ 50), indicating the number of buildings. Each of the next n input lines describes a building. A building is described by three integers: s (1 ≤ s ≤ 98), indicating the lower-left corner of the building, w (1 ≤ w ≤ 98), indicating the width of the building, and h (1 ≤ h ≤ 100), indicating the height of the building. Assume s + w ≤ 99, i.e., no building will end beyond (99,0).

출력

Print the total distance travelled by Lulu.

제한

예제 입력 1

2
40 3 7
60 10 12

예제 출력 1

138

예제 입력 2

2
43 10 12
40 3 7

예제 출력 2

124

예제 입력 3

3
40 3 7
43 10 12
53 20 8

예제 출력 3

124

예제 입력 4

3
70 20 8
40 3 7
43 10 12

예제 출력 4

140

예제 입력 5

4
12 2 10
14 4 20
18 6 15
24 8 25

예제 출력 5

160

노트

Picture illustrating the last Sample Input:

출처

University > University of Central Florida > 2021 Local Programming Contest (Final Round) 4번

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

출처

대학교 대회

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

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