View

https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV134DPqAA8CFAYh&categoryId=AV134DPqAA8CFAYh&categoryType=CODE

SW Expert Academy [D2]

쉬운 문제이다.

풀이

i번째 빌딩에서 조망권이 확보 되는 세대는 다음과 같은 조건을 충족시킨다.

  1. i번째 빌딩 높이 > i-1번째, i-2번째, i+1번째, i+2번째 빌딩 높이

  2. 세대 수 = i번째 빌딩 높이 - max( i-1번째, i-2번째, i+1번째, i+2번째 빌딩 높이)

Comments