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

업데이트:



문제 정보


풀이

문제

There are three mobile operators in Iran. Each operator has different prices for call and data usage, given in the table below. All prices are in Rials:

# Name Call (per minute) Data (per megabyte)

1 ParsTel 30 40

2 ParsCell 35 30

3 ParsPhone 40 20

Some foreign students have arrived Iran to participate in the ACM-ICPC, Tehran Site. They already know how many minutes they will call, and how much Internet they will use. For each student, you want to recommend an operator to minimize the total cost of call usage and data usage for that student.

입력 요약
Each line of the input contains the information of one student. For each student, there are two positive integers c and d (1 ≤ c, d ≤ 1000) that show the amount of call (in minutes) and data usage (in megabytes) for the student, respectively. …

출력 요약
For each student, print a line containing the minimum total cost of call usage and data usage.

코드

l=[[30,40],[35,30],[40,20]]
while True:
    a,b=map(int,input().split())
    if a==b==0:break
    print(min([i[0]*a+i[1]*b for i in l]))

설명

핵심은 구현 관점에서 There are three mobile operators in Iran. Each operator has different prices for call and data usage, given in the table below. …를 만족하도록 로직을 구성하는 것입니다.

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

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



다음 읽을거리

관련 허브 페이지에서 같은 주제의 글을 이어서 확인할 수 있습니다.

댓글남기기