[백준/파이썬] 18330번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 18330번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
The government of Neverland has recently announced a new petrol rationing plan with an unexpected price hike. According to the new plan, each person receives a quota of 60 liters per month in a fuel card. Each liter of petrol costs 1500 Oshloobs if it is within quota. Any extra fueling costs 3000 Oshloobs per liter.
After recovering from the shock, Mahya is trying to figure out how dark is the future. The current month is coming to an end, and Mahya has some quota left in her fuel card, remaining available for the next month. …
입력 요약
The input consists of two lines. The first line contains an integer n (0 ⩽ n ⩽ 200), specifying the amount of petrol that will be used in the next month. The second line contains an integer k (0 ⩽ k ⩽ 360), showing the quota left in Mahya’s fuel card at the end of current month.
출력 요약
Print the amount of money (in Oshloobs) that Mahya will pay for petrol in the next month.
코드
n, m = int(input()), int(input())
a = min(m + 60, n)
b = n - a
print(a * 1500 + b * 3000)
설명
핵심은 구현 관점에서 The government of Neverland has recently announced a new petrol rationing plan with an unexpected price hike. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기