노베이스 알고리즘 공부 #15. 백준 15059 Hard choice - Python

Anny·2024년 6월 14일
0

https://www.acmicpc.net/problem/15059

1. 문제

-- The flight attendant in this flight decided to change the procedure. First she will ask all passengers what choice of meal they would prefer, and then she will check if the number of meals available in this flight for each choice are enough.
-- Given the quantity of meals available for each choice and the number of meals requested for each choice, could you please help the flight attendant to determine how many passengers will surely not receive their selection for a meal?
-- 대충 항공기에서 기내식을 나눠 줄 때 치킨, 비프, 파스타 중 선택해야함, 이 때 승객들이 얼마나 어느 메뉴를 원하는지 모르는 이슈 발생, 따라서 승객들 중 원하는 메뉴를 배식 받지 못한 수를 구하는 문제

입력
-- 첫째줄에는 배식 가능한 치킨, 비프, 파스타의 수량이 제공
-- 둘째줄에는 승객들이 원하는 치킨, 비프, 파스타의 수량이 제공

2. 풀이

2-1. 접근

  1. 준비된 기내식 양이 승객들이 원하는 양보다 적을 경우에만
  2. 각 메뉴 별로 승객이 원하는 양 - 기내식 양을 계산
  3. 마지막에 각 메뉴별 양을 다 더한다

2-2. 정답

a, b, c = map(int, input().split())
r_a, r_b, r_c = map(int, input().split())
n_a = 0
n_b = 0
n_c = 0

if a < r_a:
    n_a = r_a - a

if b < r_b:
    n_b = r_b - b

if c < r_c:
    n_c = r_c - c

print(n_a+n_b+n_c)

다시 알고리즘 공부를 열심히 하자!!

profile
Newbie

0개의 댓글