๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • What would life be If we had no courage to attemp anything?
Problem Solving/SWEA

swea.view

by DevIseo 2022. 3. 6.

๋ฌธ์ œ์˜ ์ €์ž‘๊ถŒ์€ 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

๋Œ“๊ธ€