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

28307번 - Trianglane 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB44422512752.263%

문제

Bocchi the Builder has just finished constructing her latest project: a pathway consisting of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck, and she accidentally spilled black paint on some of the tiles! Now, she must purchase warning tape to block off the wet areas. Can you help her determine how many meters of tape she needs?

The first triangle will always point upwards, and any pair of adjacent tiles (that is, tiles that share a common side) will point in opposite directions. Every triangle has a side length of 1 meter.

입력

The first line will consist of one integer, $C,ドル representing the number of columns.

The next two lines will each consist of $C$ integers separated by spaces. Each integer represents the colour of a tile in the room, with 1 indicating that the tile is black and 0 indicating that the tile is white.

출력

Output a single integer representing the length of the tape Bocchi must purchase in meters.

제한

  • 1ドル \le C \le 200,000円$

예제 입력 1

5
1 0 1 0 1
0 0 0 0 0

예제 출력 1

9

The tiles are painted as follows, creating three wet areas. Bocchi will need 9 metres of warning tape as shown in yellow.

예제 입력 2

7
0 0 1 1 0 1 0
0 0 1 0 1 0 0

예제 출력 2

11

The tiles are painted as follows, creating three wet areas. Bocchi will need 5 metres of warning tape to surround one area and 3 metres of warning tape to surround each of the other two areas as shown in yellow.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2023 > CCC 2023 Junior Division 4번

Olympiad > Canadian Computing Competition & Olympiad > 2023 > CCC 2023 Senior Division 1번

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

출처

대학교 대회

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

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