kimTH65 / Coding

Coding Practice
0 stars 0 forks source link

코딩 문제 풀이 26(AtCoder) - Python #26

Open kimTH65 opened 3 months ago

kimTH65 commented 3 months ago

日立ヴァンタラプログラミングコンテスト2024(AtCoder Beginner Contest 368)

C - Triple Attack image

kimTH65 commented 3 months ago
N = int(input())
H = list(map(int,input().split()))
answer = 0
for i in range(N):
    h_sel = H[i]
    if answer % 3 == 1:
        if h_sel >= 2 :
            h_sel -= 4 
            answer += 2
        else :
            h_sel -= 4 
            answer += 1
    elif answer % 3 == 2:
        h_sel -= 3
        answer +=1

    if (h_sel > 0) :
        a = h_sel //5 
        b = h_sel % 5
        answer += a * 3

        if  b > 3 :
            b = 3 

        answer += b

print(answer)