관리 메뉴

솜씨좋은장씨

[BaekJoon] 10707번 : 수도요금 (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 10707번 : 수도요금 (Python)

솜씨좋은장씨 2022. 4. 9. 17:14
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 수도요금 입니다.

 

10707번: 수도요금

JOI군이 살고 있는 지역에는 X사와 Y사, 두 개의 수도회사가 있다. 두 회사의 수도요금은 한 달간 수도의 사용량에 따라 다음과 같이 정해진다. X사 : 1리터당 A엔. Y사 : 기본요금은 B엔이고, 사용량

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def x_company(A, P):
    return A * P


def y_company(B, C, D, P):
    extra_p = P - C
    extra_bill = 0
    
    if extra_p > 0:
        extra_bill = extra_p * D
    
    y_company_bill = B + extra_bill
    
    return y_company_bill


def water_bill(A, B, C, D, P):
    x_company_bill = x_company(A, P)
    y_company_bill = y_company(B, C, D, P)
    
    return min(x_company_bill, y_company_bill)


if __name__ == "__main__":
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    P = int(input())
    
    print(water_bill(A, B, C, D, P))
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments