[백준/파이썬] 11795번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 11795번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
ICPC donation center is preparing donation packages for people who faced disaster in every area in Thailand. The center gets several kinds of donation. In this year, the center gets a request to pack the basic items in one package which consists of three sets. The first set, called SetA, is water and beverage. The second one, SetB, consists of instant noodle, canned food and rice. And the last set, SetC, is first aid kits and tissue paper. In every day, we try to pack and distribute donation packages as many as possible. …
입력 요약
The input will start with an integer T (1<= T <= 365), the number of consecutive donation days. The next T lines show donation in each day, consisting of three integers: the number of setA, SetB and setC, respectively.
출력 요약
For each day, print out the maximum number of packages to be distributed on that day. If the packages cannot be distributed on that day (number of packages is less than 30), print NO.
코드
A=B=C=0
for T in range(int(input())):
a,b,c=map(int,input().split())
A+=a
B+=b
C+=c
m=min(A,B,C)
if m<30:print('NO')
else:
A-=m
B-=m
C-=m
print(m)
설명
핵심은 구현 관점에서 ICPC donation center is preparing donation packages for people who faced disaster in every area in Thailand. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기