아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Trianglane

면접 대비

시간 제한1초메모리 제한1024 MB

요약
삼각형 타일 두 줄이 있고 일부가 검게 칠해져 있을 때, 검은 영역의 전체 둘레를 구하되 맞닿은 변은 한 번만 센다.
난이도

보통10점 중 5점

유형
배열, 구현
정답자
아직 제출이 없습니다

문제

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, CC, representing the number of columns.

The next two lines will each consist of CC 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≤C≤200,0001 \le C \le 200\\,000

예제2

  1. 예제 1

    입력
    5
    1 0 1 0 1
    0 0 0 0 0
    
    예상 출력
    9
    
  2. 예제 2

    입력
    7
    0 0 1 1 0 1 0
    0 0 1 0 1 0 0
    
    예상 출력
    11