[백준] Petrol (18330)(kotlin)

문제 설명

백준 18330번 문제 링크

입력 및 출력

» 입력

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.

예제 입출력

입력 출력
41
0
61500
125
40
225000

문제 풀이1

import java.util.Scanner

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val petrolNextMonth = nextInt()
    val quotaLeft = nextInt()

    val nextMonthPetrolNeeds = (quotaLeft + 60) - petrolNextMonth
    println(
        if (nextMonthPetrolNeeds >= 0) petrolNextMonth * 1500
        else ((quotaLeft + 60) * 1500) + (petrolNextMonth - quotaLeft - 60) * 3000
    )
}