๋ฌธ์ ์ ์ ์๊ถ์ SWexpert(swea)์ ์์ต๋๋ค.
T = 10
for tc in range(1, T+1):
N = int(input())
arr = list(map(int, input().split()))
view = 0
for i in range(2, N-2): # ์กฐ๋ง๊ถ์ ํ์ธํ๊ธฐ
a = arr[i-2] if arr[i-2] > arr[i-1] else arr[i-1]
b = arr[i+2] if arr[i+2] > arr[i+1] else arr[i+1]
maxV = a if a>b else b
if arr[i] > maxV: # ์กฐ๋ง๊ถ์ด ์์
view += arr[i] - maxV
print(f'#{tc} {view}')
'Problem Solving > SWEA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
swea4021.์๋ฆฌ์ฌ (0) | 2022.04.07 |
---|---|
swea2117.ํ ๋ฐฉ๋ฒ ์๋น์ค (0) | 2022.04.07 |
swea.14195 ๋ฏธ์๋ฌผ ๊ด์ฐฐ (0) | 2022.04.06 |
swea. ์ ๊ธฐ๋ฒ์ค (0) | 2022.03.06 |
swea. min max (0) | 2022.03.06 |
๋๊ธ