코딩테스트/SW Expert

[SWEA] 1284. 수도 요금 경쟁

jhk828 2021. 1. 30. 17:25

1284. 수도 요금 경쟁

swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV189xUaI8UCFAZN&categoryId=AV189xUaI8UCFAZN&categoryType=CODE&problemTitle=&orderBy=INQUERY_COUNT&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

import java.util.Scanner;

// 210130
// 1284. 수도 요금 경쟁
public class SWEA1284 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int T = sc.nextInt();

		for (int tc = 1; tc <= T; tc++) {
			int P = sc.nextInt();
			int Q = sc.nextInt();
			int R = sc.nextInt();
			int S = sc.nextInt();
			int W = sc.nextInt();
			
			int A = W * P;
			int B;
			if (W <= R) B = Q;
			else B = Q + (W-R) * S;
			
			int res = (A<B ? A : B);
			// 출력
			System.out.println("#" + tc + " " + res);
		
		} // for

		sc.close();
	} // main
}