[백준/파이썬] 15059번 풀이

업데이트:



문제 정보


풀이

문제

In long flights, airlines offer hot meals. Usually the flight attendants push carts containing the meals down along the aisles of the plane. When a cart reaches your row, you are asked right away: “Chicken, beef, or pasta?” You know your choices, but you have only a few seconds to choose and you don’t know how your choice will look like because your neighbor hasn’t opened his wrap yet. . .

The flight attendant in this flight decided to change the procedure. …

입력 요약
The first line contains three integers Ca, Ba and Pa (0 ≤ Ca, Ba, Pa ≤ 100), representing respectively the number of meals available for chicken, beef and pasta. …

출력 요약
Output a single line with an integer representing the number of passengers that will surely not receive their selection for a meal.

코드

l1,l2=list(map(int,input().split())),list(map(int,input().split()))
def f(a,b):
    t=b-a
    return t if t>0 else 0
print(sum(map(lambda x: f(l1[x],l2[x]) ,[i for i in range(len(l1))])))

설명

핵심은 구현 관점에서 In long flights, airlines offer hot meals. Usually the flight attendants push carts containing the meals down along the aisles of the plane. …를 만족하도록 로직을 구성하는 것입니다.

코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.

경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.



이런 주제는 어떠신가요?

비슷한 난이도와 유형의 문제를 이어서 보면 풀이 감각을 더 빠르게 잡기 좋습니다.

댓글남기기