본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 17273번 카드 공장 (Small)

by 현장 2024. 2. 5.

-Code

n, m = map(int, input().split())
cards = list(map(int, input().split()))
card_front = cards[:n]
card_back = cards[n:]
now_card = cards[:n]

for _ in range(m):
    k = int(input())
    for i in range(n):
        if now_card[i] <= k:
            if now_card[i] == card_front[i]:
                now_card[i] = card_back[i]
            else:
                now_card[i] = card_front[i]
print(sum(now_card))