반응형
import java.util.Scanner;
public class waterBill {
public static void main(String[] args) {
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사 금액
int Q = sc.nextInt(); // 기본요금
int R = sc.nextInt(); // R리터 기준
int S = sc.nextInt(); // R 리터 이후 부터 요금
int W = sc.nextInt(); // 물 총리터
int resultA = P * W;
int resultB = W<=R ? Q : Q + (W-R) * S;
int result = Math.min(resultA, resultB);
System.out.println("#"+test_case + " " + result);
}
}
}반응형
'알고리즘 문제풀이' 카테고리의 다른 글
| [SWEA][D2] 1288. 새로운 불면증 치료 Java (0) | 2025.06.04 |
|---|---|
| [SWEA][D2] 1928. Base64 Decoder Java (0) | 2025.06.04 |
| [SWEA][D2] 1204 1일차 - 최빈수 구하기 Java (0) | 2025.06.03 |
| [SWEA][D2] 1946. 간단한 압축 풀기 Java (0) | 2025.06.03 |
| [SWEA][D2] 1948. 날짜 계산기 Java (0) | 2025.06.03 |