python-algorithm

백준 25881 Electric Bill

무적김두칠 2022. 11. 29. 23:37

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

 

25881번: Electric Bill

The first input line contains two integers (each between 2 and 20, inclusive), indicating the rate/KWH for the first 1000 KWH and the rate/KWH for the additional usage, respectively. The next input line contains a positive integer, n, indicating the number

www.acmicpc.net

 

1
2
3
4
5
6
7
if __name__ == '__main__':
    first_price, second_price = map(int, (input().split()))
    n = int(input())
    for _ in range(n):
        kwh = int(input())
        total = min(1000, kwh)*first_price + max(kwh-1000,0)*second_price
        print(kwh, total)
cs
반응형