반응형
1284. 수도 요금 경쟁
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
코드
import java.util.*;
class Solution {
public static void main(String args[]) throws Exception {
//System.setIn(new FileInputStream("res/input.txt"));
Scanner sc = new Scanner(System.in);
int T;
T = sc.nextInt();
for (int test_case = 1; test_case <= T; test_case++) {
int P = sc.nextInt(); // A사의 1L당 요금
int Q = sc.nextInt(); // B사의 RL이하 시 Q 요금
int R = sc.nextInt();
int S = sc.nextInt(); // B사의 RL초과 시 1L당 S 요금
int W = sc.nextInt(); // 한달 사용 수도 양
int fareA = P * W;
int fareB = Q;
if(W > R) {
fareB += (W-R) * S;
}
System.out.printf("#%d %d\n", test_case, Math.min(fareA, fareB));
}
}
}
반응형
'CodingTEST' 카테고리의 다른 글
[백준 2667] 단지번호붙이기 (JAVA) (0) | 2023.11.18 |
---|---|
[SW Expert D2] 1204. 최빈수 구하기 (0) | 2023.11.18 |
[SW Expert D2] 1288. 새로운 불면증 치료법 (0) | 2023.11.18 |
[SW Expert D2] 1940. 가랏! RC카! (0) | 2023.11.18 |
[SW Expert D2] 1946. 간단한 압축 풀기 (0) | 2023.11.18 |